Run migrations with immediate foreign key checks
This fixes an issue where unrelated foreign key violations may cause migrations to fail.
This commit is contained in:
parent
a1eb9e3042
commit
ea627259fb
@ -241,7 +241,10 @@ public class GRDBSchemaMigrator: NSObject {
|
||||
var migrator = DatabaseMigrator()
|
||||
|
||||
func registerMigration(_ identifier: MigrationId, migrate: @escaping (Database) -> Void) {
|
||||
migrator.registerMigration(identifier.rawValue) { (database: Database) in
|
||||
// Run with immediate foreign key checks so that pre-existing dangling rows
|
||||
// don't cause unrelated migrations to fail. We also don't perform schema
|
||||
// alterations that would necessitate disabling foreign key checks.
|
||||
migrator.registerMigration(identifier.rawValue, foreignKeyChecks: .immediate) { (database: Database) in
|
||||
let startTime = CACurrentMediaTime()
|
||||
Logger.info("Running migration: \(identifier)")
|
||||
migrate(database)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user