Skip to content
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

Rails/ReversibleMigration - False positive with change_table_comment #144

Closed
DNA opened this issue Oct 31, 2019 · 0 comments · Fixed by #145
Closed

Rails/ReversibleMigration - False positive with change_table_comment #144

DNA opened this issue Oct 31, 2019 · 0 comments · Fixed by #145
Labels
bug Something isn't working

Comments

@DNA
Copy link
Contributor

DNA commented Oct 31, 2019

Rails/ReversibleMigration cop throw an offense even when the method change_table_comment pass a hash with :from and :to

Expected behavior

Only throw an offense if it's not a hash with :from and :to

Actual behavior

db/migrate/20191031164441_add_comments_to_table.rb:5:5: C: Rails/ReversibleMigration: change_table_comment is not reversible.
    change_table_comment :foo, from: 'old_comment', to: 'new_comment'
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Steps to reproduce the problem

Just create a migration with change_table_comment

class AddComentsToPosts < ActiveRecord::Migration[6.0]
  def change
    change_table_comment :foo, from: 'old comment', to: 'new_comment'
  end
end

RuboCop version

$ [bundle exec] rubocop -V
0.76.0 (using Parser 2.6.5.0, running on ruby 2.5.7 x86_64-linux)
DNA added a commit to DNA/rubocop-rails that referenced this issue Oct 31, 2019
change_table_comment is onli irreversible when passing a string as the
comment. If we pass a hash with `:from` and `:to`, it works as a
reversible migration

Fixes rubocop#144
DNA added a commit to DNA/rubocop-rails that referenced this issue Oct 31, 2019
change_table_comment is only irreversible when passing a string as
the comment. If we pass a hash with `:from` and `:to` keys, it
works as a reversible migration

Fixes rubocop#144
DNA added a commit to DNA/rubocop-rails that referenced this issue Oct 31, 2019
change_table_comment is only irreversible when passing a string as
the comment. If we pass a hash with `:from` and `:to` keys, it
works as a reversible migration

Fixes rubocop#144
@koic koic added the bug Something isn't working label Nov 1, 2019
DNA added a commit to DNA/rubocop-rails that referenced this issue Nov 4, 2019
change_table_comment is only irreversible when passing a string as
the comment. If we pass a hash with `:from` and `:to` keys, it
works as a reversible migration

Fixes rubocop#144
DNA added a commit to DNA/rubocop-rails that referenced this issue Nov 4, 2019
change_table_comment is only irreversible when passing a string as
the comment. If we pass a hash with `:from` and `:to` keys, it
works as a reversible migration

Fixes rubocop#144
@koic koic closed this as completed in #145 Nov 11, 2019
koic added a commit that referenced this issue Nov 11, 2019
[Fix #144] false positive for `Rails/ReversibleMigration`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants