Skip to content

Instantly share code, notes, and snippets.

@cweinberger
Last active May 31, 2020 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cweinberger/a81e6af7abf4c1f3694ec7faf8b73156 to your computer and use it in GitHub Desktop.
Save cweinberger/a81e6af7abf4c1f3694ec7faf8b73156 to your computer and use it in GitHub Desktop.
Vapor 3 with Swift 5.2
import FluentMySQL
/*
Starting with Swift 5.2 the compiler is not able to resolve this automatically:
`migrations.add(model: Todo.self, database: .mysql)`
See: https://forums.swift.org/t/vapor-3-swift-5-2-regression/34764
Instead of adding this to each model, I added these extensions.
*/
extension MySQLModel {
typealias Database = MySQLDatabase
}
extension MySQLUUIDModel {
typealias Database = MySQLDatabase
}
extension MySQLStringModel {
typealias Database = MySQLDatabase
}
extension MySQLPivot {
typealias Database = MySQLDatabase
}
extension MySQLUUIDPivot {
typealias Database = MySQLDatabase
}
extension MySQLStringPivot {
typealias Database = MySQLDatabase
}
import FluentPostgreSQL
/*
Starting with Swift 5.2 the compiler is not able to resolve this automatically:
`migrations.add(model: Todo.self, database: .psql)`
See: https://forums.swift.org/t/vapor-3-swift-5-2-regression/34764
Instead of adding this to each model, I added these extensions.
*/
extension PostgreSQLModel {
typealias Database = PostgreSQLDatabase
}
extension PostgreSQLUUIDModel {
typealias Database = PostgreSQLDatabase
}
extension PostgreSQLStringModel {
typealias Database = PostgreSQLDatabase
}
extension PostgreSQLPivot {
typealias Database = PostgreSQLDatabase
}
extension PostgreSQLUUIDPivot {
typealias Database = PostgreSQLDatabase
}
extension PostgreSQLStringPivot {
typealias Database = PostgreSQLDatabase
}
import FluentSQLite
/*
Starting with Swift 5.2 the compiler is not able to resolve this automatically:
`migrations.add(model: Todo.self, database: .sqlite)`
See: https://forums.swift.org/t/vapor-3-swift-5-2-regression/34764
Instead of adding this to each model, I added these extensions.
*/
extension SQLiteModel {
typealias Database = SQLiteDatabase
}
extension SQLiteUUIDModel {
typealias Database = SQLiteDatabase
}
extension SQLiteStringModel {
typealias Database = SQLiteDatabase
}
extension SQLitePivot {
typealias Database = SQLiteDatabase
}
extension SQLiteUUIDPivot {
typealias Database = SQLiteDatabase
}
extension SQLiteStringPivot {
typealias Database = SQLiteDatabase
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment