-
Notifications
You must be signed in to change notification settings - Fork 596
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix system_parameter value column type and remove unnecessary FK…
…s in mysql
- Loading branch information
1 parent
761f142
commit a2345f3
Showing
3 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/meta/model_v2/migration/src/m20240702_080451_system_param_value.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use sea_orm_migration::prelude::*; | ||
|
||
use crate::sea_orm::DbBackend; | ||
|
||
#[derive(DeriveMigrationName)] | ||
pub struct Migration; | ||
|
||
#[async_trait::async_trait] | ||
impl MigrationTrait for Migration { | ||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
match manager.get_database_backend() { | ||
DbBackend::MySql => { | ||
manager | ||
.alter_table( | ||
Table::alter() | ||
.table(SystemParameter::Table) | ||
.modify_column(ColumnDef::new(SystemParameter::Value).text().not_null()) | ||
.to_owned(), | ||
) | ||
.await?; | ||
} | ||
_ => {} | ||
} | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
match manager.get_database_backend() { | ||
DbBackend::MySql => { | ||
manager | ||
.alter_table( | ||
Table::alter() | ||
.table(SystemParameter::Table) | ||
.modify_column( | ||
ColumnDef::new(SystemParameter::Value).string().not_null(), | ||
) | ||
.to_owned(), | ||
) | ||
.await?; | ||
} | ||
_ => {} | ||
} | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[derive(DeriveIden)] | ||
enum SystemParameter { | ||
Table, | ||
Value, | ||
} |
41 changes: 41 additions & 0 deletions
41
src/meta/model_v2/migration/src/m20240702_084927_unnecessary_fk.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use sea_orm_migration::prelude::*; | ||
|
||
use crate::sea_orm::DbBackend; | ||
|
||
#[derive(DeriveMigrationName)] | ||
pub struct Migration; | ||
|
||
#[async_trait::async_trait] | ||
impl MigrationTrait for Migration { | ||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
match manager.get_database_backend() { | ||
DbBackend::MySql => { | ||
manager | ||
.alter_table( | ||
Table::alter() | ||
.table(Alias::new("sink")) | ||
.drop_foreign_key(Alias::new("FK_sink_connection_id")) | ||
.drop_foreign_key(Alias::new("FK_sink_target_table_id")) | ||
.to_owned(), | ||
) | ||
.await?; | ||
manager | ||
.alter_table( | ||
Table::alter() | ||
.table(Alias::new("source")) | ||
.drop_foreign_key(Alias::new("FK_source_connection_id")) | ||
.to_owned(), | ||
) | ||
.await?; | ||
} | ||
_ => {} | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> { | ||
// Do nothing. | ||
Ok(()) | ||
} | ||
} |