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()
    }
}
