Add password reset model

This commit is contained in:
Christoph Hagen
2022-10-11 12:04:15 +02:00
parent e49cc9cb91
commit 16ab0fd6d3
4 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,18 @@
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()
}
}