Add sidenotes

This commit is contained in:
Adrian Woźniak 2024-11-19 11:05:15 +01:00
parent b84e09ed28
commit 99fc54eea9

View File

@ -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,
}