deferred
The migration runs with disabled foreign keys.
case deferred
Foreign keys are checked right before changes are committed on disk, unless the DatabaseMigrator
is the result of disablingDeferredForeignKeyChecks
.
In this case, you can perform your own deferred foreign key checks with checkForeignKeys(in:in:)
or checkForeignKeys
:
migrator = migrator.disablingDeferredForeignKeyChecks()
migrator.registerMigration("Partially checked migration") { db in
...
// Throws an error and stops migrations if there exists a
// foreign key violation in the 'book' table.
try db.checkForeignKeys(in: "book")
}