use sea_orm::sea_query::{ColumnDef, Table};
use sea_orm::{DbErr, DeriveIden};
use sea_orm_migration::{MigrationName, MigrationTrait, SchemaManager};
pub struct Migration;
impl MigrationName for Migration {
fn name(&self) -> &str {
"m_20261019_000014_add_reminders_to_calendar"
}
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
// SQLite takes one column per ALTER TABLE
let columns = [
ColumnDef::new(Calendar::SigDateDelta)
.integer()
.null()
.to_owned(),
ColumnDef::new(Calendar::SigRemindEnum)
.string()
.null()
.to_owned(),
ColumnDef::new(Calendar::Meta)
.json_binary()
.null()
.to_owned(),
];
for mut col in columns {
manager
.alter_table(
Table::alter()
.table(Calendar::Table)
.add_column(&mut col)
.to_owned(),
)
.await?;
}
Ok(())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
for col in [
Calendar::SigDateDelta,
Calendar::SigRemindEnum,
Calendar::Meta,
] {
manager
.alter_table(
Table::alter()
.table(Calendar::Table)
.drop_column(col)
.to_owned(),
)
.await?;
}
Ok(())
}
}
/// How far ahead, and how often, the motd mentions a calendar's holidays.
/// Rows keyed "group:countries" and the like hold the defaults for a group.
#[derive(DeriveIden)]
pub enum Calendar {
Table,
SigDateDelta,
SigRemindEnum,
Meta,
}
⭐
Log in to mark this repository.
1.9 KiB · text
History
aea77cc