From 99fc54eea9ef1611aa3acc41b2be8afbf33f11fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Wo=C5=BAniak?= Date: Tue, 19 Nov 2024 11:05:15 +0100 Subject: [PATCH] Add sidenotes --- ...00003_add_sidenote_to_recipe_ingredient.rs | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 migration/src/m20220101_000003_add_sidenote_to_recipe_ingredient.rs 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, +}