use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[derive(DeriveIden)]
enum Users {
Table,
Id,
Name,
Email,
Password,
EmailVerifiedAt,
HasUsablePassword,
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(Users::Table)
.if_not_exists()
.col(ColumnDef::new(Users::Id).big_integer().not_null().auto_increment().primary_key())
.col(ColumnDef::new(Users::Name).string().not_null())
.col(ColumnDef::new(Users::Email).string().not_null().unique_key())
.col(ColumnDef::new(Users::Password).string().not_null())
.col(ColumnDef::new(Users::EmailVerifiedAt).timestamp_with_time_zone().null())
.col(ColumnDef::new(Users::HasUsablePassword).boolean().not_null().default(true))
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager.drop_table(Table::drop().table(Users::Table).to_owned()).await
}
}