Skip to content

Commit

Permalink
migrate the db model
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Chien <[email protected]>
  • Loading branch information
stdrc committed Nov 15, 2024
1 parent 7c297ff commit 98daf1b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/meta/model/migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
]
}
}
Original file line number Diff line number Diff line change
@@ -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,
}
2 changes: 0 additions & 2 deletions src/meta/model/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ pub struct Model {
pub compressed_binary: Option<Vec<u8>>,
pub kind: FunctionKind,
pub always_retry_on_network_error: bool,
pub function_type: Option<String>, // TODO()
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down Expand Up @@ -108,7 +107,6 @@ impl From<PbFunction> 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(),
}
}
}

0 comments on commit 98daf1b

Please sign in to comment.