     /// migration has not yet been applied, its block is executed in
     /// a transaction.
     ///
-    /// - parameter db: A DatabaseWriter (DatabaseQueue or DatabasePool) where
-    ///   migrations should apply.
+    /// - 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 {

    /// provided target. If a migration has not yet been applied, its block is
    /// executed in a transaction.
    ///
    /// - parameter db: A DatabaseWriter (DatabaseQueue or DatabasePool) where
    ///   migrations should apply.
    /// - targetIdentifier: The identifier of a registered migration.
    /// - throws: An eventual error thrown by the registered migration blocks.
    public func migrate(_ writer: DatabaseWriter, upTo targetIdentifier: String) throws {
        if eraseDatabaseOnSchemaChange {

        
        // targetIdentifier must refer to a registered migration
        GRDBPrecondition(
            expectedMigrations.last?.identifier == targetIdentifier,
            "undefined migration: \(String(reflecting: targetIdentifier))")
        
        return expectedMigrations.filter { !appliedIdentifiers.contains($0.identifier) }
    }
    
    private func runMigrations(_ db: Database, upTo targetIdentifier: String) throws {
        let appliedIdentifiers = try self.appliedIdentifiers(db)
        
        // Subsequent migration must not be applied
        if let index = migrations.firstIndex(where: { $0.identifier == targetIdentifier }),
            migrations[(index + 1)...].contains(where: { appliedIdentifiers.contains($0.identifier) })
        {
            fatalError("database is already migrated beyond migration \(String(reflecting: targetIdentifier))")
        }
        
        let unappliedMigrations = self.unappliedMigrations(
            upTo: targetIdentifier,
            appliedIdentifiers: appliedIdentifiers)
        
        for migration in unappliedMigrations {
            try migration.run(db)
        }
    }
