         return try Set(String.fetchAll(db, sql: "SELECT identifier FROM grdb_migrations"))
     }
     
-    private func runMigrations(_ db: Database, upTo targetIdentifier: String) throws {
-        var prefixMigrations: [Migration] = []
+    /// Returns unapplied migration identifier,
+    private func unappliedMigrations(upTo targetIdentifier: String, appliedIdentifiers: Set<String>) -> [Migration] {
+        var expectedMigrations: [Migration] = []
         for migration in migrations {
-            prefixMigrations.append(migration)
+            expectedMigrations.append(migration)
             if migration.identifier == targetIdentifier {
                 break
             }

    }
    
    /// Returns the set of applied migration identifiers.
    public func appliedMigrations(in reader: DatabaseReader) throws -> Set<String> {
        return try reader.read { db in
            return try appliedIdentifiers(db)
        }
    }
    
    
    // MARK: - Non public
    

    /// migration has not yet been applied, its block is executed in
    /// a transaction.
    ///
    /// - parameter writer: A DatabaseWriter (DatabaseQueue or DatabasePool)
    ///   where migrations should apply.
    /// - throws: An eventual error thrown by the registered migration blocks.
    public func migrate(_ writer: DatabaseWriter) throws {
        guard let lastMigration = migrations.last else {
