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
{{ message }}
This repository has been archived by the owner on May 13, 2022. It is now read-only.
What's strange is that the "up" migration works while "down" fails with this message :
StandardError: An error has occurred, this and all later migrations canceled:
PG::DuplicateTable: ERREUR: the relation « fk__customers_profile_id » already exists:
CREATE INDEX "fk__customers_profile_id" ON "customers" ("profile_id")
Please note that even for the "up" migration, the foreign key ALREADY exists. I just wanted to alter on_delete and on_update to :cascade (and revert them to :no_action on rollback)
The text was updated successfully, but these errors were encountered:
More interresting is that after the "up migration" call to change_column an index fk__[table]_[reftable]_[refcolumn] has been created.
This index cause the rollback migration to fail (and the prevent the "up migration" to be run again).
The fact is that this index is a duplicate as foreign keys are already indexed with PostgreSQL. Seems that add_column (or t.integer :column, :foreign_key => true) takes that in account while change_column don't.
This is how the distributors table looks like in schema.rb after running the "up migration" :
I coded this migration :
What's strange is that the "up" migration works while "down" fails with this message :
Please note that even for the "up" migration, the foreign key ALREADY exists. I just wanted to alter on_delete and on_update to :cascade (and revert them to :no_action on rollback)
The text was updated successfully, but these errors were encountered: