47 lines
1.4 KiB
Rust
47 lines
1.4 KiB
Rust
use sea_orm_migration::prelude::*;
|
|
|
|
#[derive(DeriveMigrationName)]
|
|
pub struct Migration;
|
|
|
|
#[async_trait::async_trait]
|
|
impl MigrationTrait for Migration {
|
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.create_table(
|
|
Table::create()
|
|
.table(User::Table)
|
|
.if_not_exists()
|
|
.col(
|
|
ColumnDef::new(User::Id)
|
|
.big_integer()
|
|
.not_null()
|
|
.primary_key(),
|
|
)
|
|
.col(ColumnDef::new(User::Username).text().not_null())
|
|
.col(ColumnDef::new(User::Email).text().not_null())
|
|
.col(ColumnDef::new(User::PasswordHash).text().not_null())
|
|
.col(ColumnDef::new(User::Bio).string().not_null().default(""))
|
|
.col(ColumnDef::new(User::Flags).integer().not_null().default(0))
|
|
.to_owned(),
|
|
)
|
|
.await
|
|
}
|
|
|
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.drop_table(Table::drop().table(User::Table).to_owned())
|
|
.await
|
|
}
|
|
}
|
|
|
|
/// Learn more at https://docs.rs/sea-query#iden
|
|
#[derive(Iden)]
|
|
pub enum User {
|
|
Table,
|
|
Id,
|
|
Username,
|
|
Email,
|
|
PasswordHash,
|
|
Bio,
|
|
Flags,
|
|
}
|