risingwave_meta_model_migration/
m20250210_170743_function_options.rs

1use 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        assert!(manager.has_table(Function::Table.to_string()).await?);
10
11        manager
12            .alter_table(
13                MigrationTable::alter()
14                    .table(Function::Table)
15                    .add_column(ColumnDef::new(Function::Options).json_binary())
16                    .to_owned(),
17            )
18            .await?;
19
20        Ok(())
21    }
22
23    async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
24        assert!(manager.has_table(Function::Table.to_string()).await?);
25
26        manager
27            .alter_table(
28                MigrationTable::alter()
29                    .table(Function::Table)
30                    .drop_column(Alias::new(Function::Options.to_string()))
31                    .to_owned(),
32            )
33            .await?;
34
35        Ok(())
36    }
37}
38
39#[derive(DeriveIden)]
40enum Function {
41    Table,
42    Options,
43}