move fix to private

This commit is contained in:
Michael Kirk committed 2019-11-18 11:33:35 -07:00
1 parent 9ea160b116
commit cd6d46e349
1 file changed
+6 -8
+6 -8
View File
@@ -214,14 +214,6 @@ public struct DatabaseMigrator {
/// Returns the set of applied migration identifiers.
public func appliedMigrations(in reader: DatabaseReader) throws -> Set<String> {
return try reader.read { db in
guard let doesMigrationsTableExist = try Bool.fetchOne(db, sql: "SELECT EXISTS (SELECT 1 FROM sqlite_master WHERE type='table' AND name='grdb_migrations')") else {
fatalError("grdb_migrations check unexpectedly returned nil")
}
guard doesMigrationsTableExist else {
return Set()
}
return try appliedIdentifiers(db)
}
}
@@ -241,6 +233,12 @@ public struct DatabaseMigrator {
}
private func appliedIdentifiers(_ db: Database) throws -> Set<String> {
let tableExists = try Bool.fetchOne(db, sql: """
SELECT EXISTS (SELECT 1 FROM sqlite_master WHERE type='table' AND name='grdb_migrations')
""")!
guard tableExists else {
return []
}
return try Set(String.fetchAll(db, sql: "SELECT identifier FROM grdb_migrations"))
}