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
It looks like SQLite automatically migrates foreign keys when tables are renamed, but not when columns are renamed (documentation).
I recently had to rename a foreign key, and I had to run the migration with immediate foreign key checks in order to avoid integrity failures:
// Use immediate foreign key checks so that the foreign key is properly migrated.
migrator.registerMigration("v8", foreignKeyChecks:.immediate){ db intry db.rename(table:"foo", to:"bar")try db.alter(table:"qux"){ t in
t.rename(column:"fooId", to:"barId")}}
This must be documented, because it is far from obvious.
The text was updated successfully, but these errors were encountered:
... so that SQLite updates the foreign key.
It looks like SQLite automatically migrates foreign keys when tables are renamed, but not when columns are renamed (documentation).
I recently had to rename a foreign key, and I had to run the migration with immediate foreign key checks in order to avoid integrity failures:
This must be documented, because it is far from obvious.
The text was updated successfully, but these errors were encountered: