hacky-ruadat/migration/src/m20230208_114547_create_day.rs
2023-02-08 16:25:06 +01:00

48 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(Day::Table)
.if_not_exists()
.col(ColumnDef::new(Day::Day).date().not_null().primary_key())
.col(ColumnDef::new(Day::PlannedAmountCox).integer().default(0))
.col(
ColumnDef::new(Day::PlannedStartingTime)
.string()
.default(""),
)
.col(
ColumnDef::new(Day::OpenRegistration)
.boolean()
.not_null()
.default(true),
)
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(Day::Table).to_owned())
.await
}
}
/// Learn more at https://docs.rs/sea-query#iden
#[derive(Iden)]
enum Day {
Table,
Day,
PlannedAmountCox,
PlannedStartingTime,
OpenRegistration,
}