correctly handle updated alerts

This commit is contained in:
Sebastian Hugentobler 2024-05-11 18:37:41 +02:00
parent a8c0be2c05
commit ac0ac8a10d
Signed by: shu
GPG key ID: BB32CF3CA052C2F0
34 changed files with 775 additions and 114 deletions

View file

@ -6,42 +6,28 @@ pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
// Replace the sample below with your own migration scripts
todo!();
manager
.create_table(
Table::create()
.table(Post::Table)
.table(Alerts::Table)
.if_not_exists()
.col(
ColumnDef::new(Post::Id)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(Post::Title).string().not_null())
.col(ColumnDef::new(Post::Text).string().not_null())
.col(ColumnDef::new(Alerts::Id).string().not_null().primary_key())
.col(ColumnDef::new(Alerts::PublishDate).date_time().not_null())
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
// Replace the sample below with your own migration scripts
todo!();
manager
.drop_table(Table::drop().table(Post::Table).to_owned())
.drop_table(Table::drop().table(Alerts::Table).to_owned())
.await
}
}
#[derive(DeriveIden)]
enum Post {
enum Alerts {
Table,
Id,
Title,
Text,
PublishDate,
}