1.1 KiB · text History aea77cc
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_000015_add_url_to_calendar"
    }
}

#[async_trait::async_trait]
impl MigrationTrait for Migration {
    async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        manager
            .alter_table(
                Table::alter()
                    .table(Calendar::Table)
                    .add_column(ColumnDef::new(Calendar::Url).string().null())
                    .to_owned(),
            )
            .await
    }

    async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        manager
            .alter_table(
                Table::alter()
                    .table(Calendar::Table)
                    .drop_column(Calendar::Url)
                    .to_owned(),
            )
            .await
    }
}

/// Where a subscribed iCal calendar comes from: an http(s) or webcal URL, or a file
#[derive(DeriveIden)]
pub enum Calendar {
    Table,
    Url,
}