forked from TWS/kalkutago
Add groups table creation migration
This commit is contained in:
parent
3c4bac5256
commit
b8ffd5c0b5
46
src/migrator/m20230606_000003_create_groups_table.rs
Normal file
46
src/migrator/m20230606_000003_create_groups_table.rs
Normal file
|
@ -0,0 +1,46 @@
|
|||
use sea_orm_migration::{async_trait::async_trait, prelude::*};
|
||||
|
||||
pub struct Migration;
|
||||
|
||||
impl MigrationName for Migration {
|
||||
fn name(&self) -> &str {
|
||||
"m20230606_000003_create_groups_table"
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(Groups::Table)
|
||||
.col(
|
||||
ColumnDef::new(Groups::Id)
|
||||
.integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(Groups::Name).string().not_null())
|
||||
.col(ColumnDef::new(Groups::Description).string().not_null())
|
||||
.col(ColumnDef::new(Groups::Order).integer().default(-1))
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(Groups::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum Groups {
|
||||
Table,
|
||||
Id,
|
||||
Name,
|
||||
Description,
|
||||
Order,
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
mod m20230606_000001_create_tracks_table;
|
||||
mod m20230606_000002_create_ticks_table;
|
||||
mod m20230606_000003_create_groups_table;
|
||||
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
|
|
Loading…
Reference in a new issue