server: Add a person count to recipes
This commit is contained in:
parent
96a9907f7a
commit
614ff07552
4 changed files with 41 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ mod m20220101_000001_account;
|
|||
mod m20230520_203638_household;
|
||||
mod m20230529_184433_ingredients;
|
||||
mod m20230618_163416_recipe;
|
||||
mod m20230629_151746_recipe_person_count;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
|
|
@ -15,6 +16,7 @@ impl MigratorTrait for Migrator {
|
|||
Box::new(m20230520_203638_household::Migration),
|
||||
Box::new(m20230529_184433_ingredients::Migration),
|
||||
Box::new(m20230618_163416_recipe::Migration),
|
||||
Box::new(m20230629_151746_recipe_person_count::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,14 @@ use crate::{m20230520_203638_household::Household, m20230529_184433_ingredients:
|
|||
pub struct Migration;
|
||||
|
||||
#[derive(Iden)]
|
||||
enum Recipe {
|
||||
pub enum Recipe {
|
||||
Table,
|
||||
Id,
|
||||
Household,
|
||||
Name,
|
||||
Ranking,
|
||||
Steps,
|
||||
PersonCount,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
|
|
|
|||
36
migration/src/m20230629_151746_recipe_person_count.rs
Normal file
36
migration/src/m20230629_151746_recipe_person_count.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
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
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ pub struct Model {
|
|||
pub household: Uuid,
|
||||
#[sea_orm(column_type = "Text")]
|
||||
pub steps: String,
|
||||
pub person_count: i32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue