Skip to content

Instantly share code, notes, and snippets.

@maximkrouk
Last active January 28, 2020 16:38
Show Gist options
  • Save maximkrouk/2d704a9e8eaa9a7b7c72bd472076e5d9 to your computer and use it in GitHub Desktop.
Save maximkrouk/2d704a9e8eaa9a7b7c72bd472076e5d9 to your computer and use it in GitHub Desktop.
import Fluent
private struct _Migration<T>: Migration {
var preparation: (Database) -> EventLoopFuture<Void>
var revertion: (Database) -> EventLoopFuture<Void>
func prepare(on database: Database) -> EventLoopFuture<Void> { preparation(database) }
func revert(on database: Database) -> EventLoopFuture<Void> { revertion(database) }
}
public protocol MigrationProvider {
static func prepare(on database: Database) -> EventLoopFuture<Void>
static func revert(on database: Database) -> EventLoopFuture<Void>
}
extension MigrationProvider {
public static var migration: Migration {
_Migration<Self>(preparation: prepare, revertion: revert)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment