move applied migration identifiers table creation to the top of migrations execution

https://github.com/zdnk/GRDB.swift/commit/51ff937397248355d4b264aedfd5a8f05893a2b8

Thanks @zdnk :-)
This commit is contained in:
Gwendal Roué committed 2021-11-03 08:33:09 +01:00
1 parent 2273efa07f
commit 0a8967ccde
1 file changed
+1 -1
+1 -1
View File
@@ -252,6 +252,7 @@ public struct DatabaseMigrator {
}
private func runMigrations(_ db: Database, upTo targetIdentifier: String) throws {
try db.execute(sql: "CREATE TABLE IF NOT EXISTS grdb_migrations (identifier TEXT NOT NULL PRIMARY KEY)")
let appliedIdentifiers = try self.appliedMigrations(db)
// Subsequent migration must not be applied
@@ -271,7 +272,6 @@ public struct DatabaseMigrator {
return
}
try db.execute(sql: "CREATE TABLE IF NOT EXISTS grdb_migrations (identifier TEXT NOT NULL PRIMARY KEY)")
for migration in unappliedMigrations {
try migration.run(db)
}