1.0 KiB · text History 2264215
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(Topics::Table)
                    .add_column(ColumnDef::new(Topics::DeletedAt).timestamp_with_time_zone().null())
                    .add_column(ColumnDef::new(Topics::DeletedById).uuid().null())
                    .to_owned(),
            )
            .await
    }

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

#[derive(DeriveIden)]
enum Topics {
    Table,
    DeletedAt,
    DeletedById,
}