Skip to content

Instantly share code, notes, and snippets.

@littlebobert
Created May 24, 2020 18:18
Show Gist options
  • Save littlebobert/694bedae125f378b2c35c39601d9d63b to your computer and use it in GitHub Desktop.
Save littlebobert/694bedae125f378b2c35c39601d9d63b to your computer and use it in GitHub Desktop.
migration that imports from a CSV
final class MovieImport: Migration {
typealias Database = SQLiteDatabase
static func prepare(on conn: SQLiteConnection) -> EventLoopFuture<Void> {
MovieDatabase.shared.populateFromCSV(connection: conn)
return conn.eventLoop.newPromise(of: Void.self).futureResult // Is this correct?
}
static func revert(on conn: SQLiteConnection) -> EventLoopFuture<Void> {
print("reverting")
return conn.eventLoop.newPromise(of: Void.self).futureResult
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment