Schafkopf-Server/Sources/App/Model/Migrations/PasswordResetMigration.swift

19 lines
681 B
Swift
Raw Normal View History

2022-10-11 12:04:15 +02:00
import FluentSQLiteDriver
struct PasswordResetMigration: Migration {
func prepare(on database: FluentSQLiteDriver.Database) -> EventLoopFuture<Void> {
database.schema(PasswordReset.schema)
.id()
.field(PasswordReset.Key.user.key, .uuid, .required, .references(User.schema, .id))
.unique(on: PasswordReset.Key.user.key)
.field(PasswordReset.Key.token.key, .string, .required)
.field(PasswordReset.Key.expiry.key, .date, .required)
.create()
}
func revert(on database: FluentSQLiteDriver.Database) -> EventLoopFuture<Void> {
database.schema(PasswordReset.schema).delete()
}
}