From 98daf1b2572f36c7e5155dc01962e7f8fed32dce Mon Sep 17 00:00:00 2001 From: Richard Chien Date: Fri, 15 Nov 2024 17:01:33 +0800 Subject: [PATCH] migrate the db model Signed-off-by: Richard Chien --- src/meta/model/migration/src/lib.rs | 2 ++ .../m20241115_085007_remove_function_type.rs | 35 +++++++++++++++++++ src/meta/model/src/function.rs | 2 -- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/meta/model/migration/src/m20241115_085007_remove_function_type.rs diff --git a/src/meta/model/migration/src/lib.rs b/src/meta/model/migration/src/lib.rs index b84a29891eee3..cdf3b496b0454 100644 --- a/src/meta/model/migration/src/lib.rs +++ b/src/meta/model/migration/src/lib.rs @@ -24,6 +24,7 @@ mod m20240820_081248_add_time_travel_per_table_epoch; mod m20240911_083152_variable_vnode_count; mod m20241016_065621_hummock_gc_history; mod m20241025_062548_singleton_vnode_count; +mod m20241115_085007_remove_function_type; mod utils; pub struct Migrator; @@ -86,6 +87,7 @@ impl MigratorTrait for Migrator { Box::new(m20240911_083152_variable_vnode_count::Migration), Box::new(m20241016_065621_hummock_gc_history::Migration), Box::new(m20241025_062548_singleton_vnode_count::Migration), + Box::new(m20241115_085007_remove_function_type::Migration), ] } } diff --git a/src/meta/model/migration/src/m20241115_085007_remove_function_type.rs b/src/meta/model/migration/src/m20241115_085007_remove_function_type.rs new file mode 100644 index 0000000000000..b74382991c889 --- /dev/null +++ b/src/meta/model/migration/src/m20241115_085007_remove_function_type.rs @@ -0,0 +1,35 @@ +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(Function::Table) + .drop_column(Function::FunctionType) + .to_owned(), + ) + .await + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .alter_table( + Table::alter() + .table(Function::Table) + .add_column(ColumnDef::new(Function::FunctionType).string()) + .to_owned(), + ) + .await + } +} + +#[derive(DeriveIden)] +enum Function { + Table, + FunctionType, +} diff --git a/src/meta/model/src/function.rs b/src/meta/model/src/function.rs index c7eed7df5b38e..48e9812999d67 100644 --- a/src/meta/model/src/function.rs +++ b/src/meta/model/src/function.rs @@ -49,7 +49,6 @@ pub struct Model { pub compressed_binary: Option>, pub kind: FunctionKind, pub always_retry_on_network_error: bool, - pub function_type: Option, // TODO() } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -108,7 +107,6 @@ impl From for ActiveModel { compressed_binary: Set(function.compressed_binary), kind: Set(function.kind.unwrap().into()), always_retry_on_network_error: Set(function.always_retry_on_network_error), - function_type: Default::default(), } } }