You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The remove_reference command should be considered as reversible
Actual behavior
The remove_reference command is not considered as reversible
Describe here what actually happened.
I created a migration to remove a reference from one table to another, as shown below:
# frozen_string_literal: true
class DropColumnFromMyTable < ActiveRecord::Migration[6.1]
def change
remove_reference :my_table, :my_other_table, foreign_key: true, index: true
end
end
When running rubocop, it accused that my migration is not reversible. However, I've tested a few times migrating, rolling it back and comparing the results.
From my tests, all the indexes, keys and references were created a dropped as expected.
Steps to reproduce the problem
Create a migration with rails g migration MigrationName
Try removing a reference from an existing table using remove reference
example: remove_reference :my_table, :my_other_table, foreign_key: true, index: true
Try running rubocop on the created migration and check that it accuses: Rails/ReversibleMigration: remove_reference is not reversible.
Expected behavior
The
remove_reference
command should be considered as reversibleActual behavior
The
remove_reference
command is not considered as reversibleDescribe here what actually happened.
I created a migration to remove a reference from one table to another, as shown below:
When running rubocop, it accused that my migration is not reversible. However, I've tested a few times migrating, rolling it back and comparing the results.
From my tests, all the indexes, keys and references were created a dropped as expected.
Steps to reproduce the problem
rails g migration MigrationName
remove reference
example:
remove_reference :my_table, :my_other_table, foreign_key: true, index: true
Rails/ReversibleMigration: remove_reference is not reversible.
RuboCop version
The text was updated successfully, but these errors were encountered: