Skip to content

Commit

Permalink
Added sink_into_table_column migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Shanicky Chen committed Jun 17, 2024
1 parent ba00ed7 commit b6787e8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/meta/model_v2/migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod m20240417_062305_subscription_internal_table_name;
mod m20240418_142249_function_runtime;
mod m20240506_112555_subscription_partial_ckpt;
mod m20240525_090457_secret;
mod m20240617_071625_sink_into_table_column;

pub struct Migrator;

Expand All @@ -27,6 +28,7 @@ impl MigratorTrait for Migrator {
Box::new(m20240418_142249_function_runtime::Migration),
Box::new(m20240506_112555_subscription_partial_ckpt::Migration),
Box::new(m20240525_090457_secret::Migration),
Box::new(m20240617_071625_sink_into_table_column::Migration),
]
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use sea_orm_migration::prelude::{Table as MigrationTable, *};

#[derive(DeriveMigrationName)]
pub struct Migration;

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

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

#[derive(DeriveIden)]
enum Sink {
Table,
OriginalTargetColumns,
}

0 comments on commit b6787e8

Please sign in to comment.