forked from Ruderverein-Donau-Linz/rowt
55 lines
1.5 KiB
Rust
55 lines
1.5 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)
|
|
.integer()
|
|
.not_null()
|
|
.auto_increment()
|
|
.primary_key(),
|
|
)
|
|
.col(ColumnDef::new(User::Name).string().not_null().unique_key())
|
|
.col(
|
|
ColumnDef::new(User::IsCox)
|
|
.boolean()
|
|
.not_null()
|
|
.default(false),
|
|
)
|
|
.col(
|
|
ColumnDef::new(User::IsAdmin)
|
|
.boolean()
|
|
.not_null()
|
|
.default(false),
|
|
)
|
|
.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,
|
|
Name,
|
|
IsCox,
|
|
IsAdmin,
|
|
}
|