regalade/migration/src/m20230629_151746_recipe_person_count.rs
2023-06-29 17:24:21 +02:00

36 lines
1,009 B
Rust

use sea_orm_migration::prelude::*;
use crate::m20230618_163416_recipe::Recipe;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(Recipe::Table)
.add_column(
ColumnDef::new(Recipe::PersonCount)
.integer()
.not_null()
.default(1),
)
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(Recipe::Table)
.drop_column(Recipe::PersonCount)
.to_owned(),
)
.await
}
}