-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
up_only in migration reports Rails/ReversibleMigration #5821
Labels
Comments
koic
added a commit
to koic/rubocop
that referenced
this issue
Apr 26, 2018
…bleMigration` Fixes rubocop#5821. This PR supports the following `AR::Migration#up_only` method. ```console % cat db/migrate/example.rb class AddPublishedToPosts < ActiveRecord::Migration[5.2] def change add_column :posts, :published, :boolean, default: false up_only do execute "UPDATE posts SET published = 'true'" end end end ``` http://api.rubyonrails.org/classes/ActiveRecord/Migration.html#method-i-up_only This PR fixes the following false posive when using Rails 5.2.0. ```console % rubocop db/migrate/example.rb --only Rails/ReversibleMigration Inspecting 1 file C Offenses: db/migrate/example.rb:6:7: C: Rails/ReversibleMigration: execute is not reversible. execute "UPDATE posts SET published = 'true'" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 file inspected, 1 offense detected ```
8 tasks
Thanks for the feedback. |
bbatsov
pushed a commit
that referenced
this issue
Apr 26, 2018
…ation` Fixes #5821. This PR supports the following `AR::Migration#up_only` method. ```console % cat db/migrate/example.rb class AddPublishedToPosts < ActiveRecord::Migration[5.2] def change add_column :posts, :published, :boolean, default: false up_only do execute "UPDATE posts SET published = 'true'" end end end ``` http://api.rubyonrails.org/classes/ActiveRecord/Migration.html#method-i-up_only This PR fixes the following false posive when using Rails 5.2.0. ```console % rubocop db/migrate/example.rb --only Rails/ReversibleMigration Inspecting 1 file C Offenses: db/migrate/example.rb:6:7: C: Rails/ReversibleMigration: execute is not reversible. execute "UPDATE posts SET published = 'true'" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 file inspected, 1 offense detected ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rails 5.2 introduced
up_only
method http://api.rubyonrails.org/classes/ActiveRecord/Migration.html#method-i-up_onlyRubocop reports
Rails/ReversibleMigration
violation for:Rails/ReversibleMigration: execute is not reversible
The text was updated successfully, but these errors were encountered: