calendar/migration/src/m20220101_000001_create_event_table.rs
pavel 9ae6d88c21
All checks were successful
/ upload (release) Successful in 1m54s
init
2026-02-15 23:16:26 +01:00

49 lines
1.3 KiB
Rust

use sea_orm_migration::prelude::*;
#[derive(Iden)]
enum Event {
Table,
Id,
Name,
From,
To,
}
#[derive(Iden)]
pub struct Migration;
impl MigrationName for Migration {
fn name(&self) -> &str {
"m20220101_000001_create_event_table"
}
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(Event::Table)
.if_not_exists()
.col(
ColumnDef::new(Event::Id)
.big_integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(Event::Name).string().not_null())
.col(ColumnDef::new(Event::From).timestamp().not_null())
.col(ColumnDef::new(Event::To).timestamp().not_null())
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(Event::Table).to_owned())
.await
}
}