diff --git a/migration/src/m20220101_000003_add_sidenote_to_recipe_ingredient.rs b/migration/src/m20220101_000003_add_sidenote_to_recipe_ingredient.rs new file mode 100644 index 0000000..4c66041 --- /dev/null +++ b/migration/src/m20220101_000003_add_sidenote_to_recipe_ingredient.rs @@ -0,0 +1,51 @@ +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 + .alter_table( + Table::alter() + .table(RecipeIngredient::RecipeIngredients) + .add_column(ColumnDef::new(RecipeIngredient::Sidenote).string()) + .to_owned(), + ) + .await?; + manager + .alter_table( + Table::alter() + .table(Recipe::Recipies) + .modify_column(ColumnDef::new(Recipe::Summary).string().null()) + .to_owned(), + ) + .await?; + Ok(()) + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .alter_table( + Table::alter() + .table(RecipeIngredient::RecipeIngredients) + .drop_column(RecipeIngredient::Sidenote) + .to_owned(), + ) + .await?; + Ok(()) + } +} + +#[derive(DeriveIden)] +enum Recipe { + Recipies, + Summary, +} + +#[derive(DeriveIden)] +enum RecipeIngredient { + RecipeIngredients, + Sidenote, +}