risingwave_meta_model_migration/
m20240726_063833_auto_schema_change.rs1use sea_orm_migration::prelude::{Table as MigrationTable, *};
2
3#[derive(DeriveMigrationName)]
4pub struct Migration;
5
6#[async_trait::async_trait]
7impl MigrationTrait for Migration {
8 async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
9 manager
10 .alter_table(
11 MigrationTable::alter()
12 .table(Table::Table)
13 .add_column(ColumnDef::new(Table::CdcTableId).string())
14 .to_owned(),
15 )
16 .await?;
17
18 manager
19 .alter_table(
20 MigrationTable::alter()
21 .table(WorkerProperty::Table)
22 .add_column(ColumnDef::new(WorkerProperty::InternalRpcHostAddr).string())
23 .to_owned(),
24 )
25 .await
26 }
27
28 async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
29 manager
30 .alter_table(
31 MigrationTable::alter()
32 .table(Table::Table)
33 .drop_column(Table::CdcTableId)
34 .to_owned(),
35 )
36 .await?;
37
38 manager
39 .alter_table(
40 MigrationTable::alter()
41 .table(WorkerProperty::Table)
42 .drop_column(WorkerProperty::InternalRpcHostAddr)
43 .to_owned(),
44 )
45 .await
46 }
47}
48
49#[derive(DeriveIden)]
50enum Table {
51 Table,
52 CdcTableId,
53}
54
55#[derive(DeriveIden)]
56enum WorkerProperty {
57 Table,
58 InternalRpcHostAddr,
59}