risingwave_meta_model_migration/
m20240702_084927_unnecessary_fk.rs1use sea_orm_migration::prelude::*;
2
3use crate::sea_orm::DbBackend;
4
5#[derive(DeriveMigrationName)]
6pub struct Migration;
7
8#[async_trait::async_trait]
9impl MigrationTrait for Migration {
10 async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
11 if manager.get_database_backend() == DbBackend::MySql {
12 manager
13 .alter_table(
14 Table::alter()
15 .table(Alias::new("sink"))
16 .drop_foreign_key(Alias::new("FK_sink_connection_id"))
17 .drop_foreign_key(Alias::new("FK_sink_target_table_id"))
18 .to_owned(),
19 )
20 .await?;
21 manager
22 .alter_table(
23 Table::alter()
24 .table(Alias::new("source"))
25 .drop_foreign_key(Alias::new("FK_source_connection_id"))
26 .to_owned(),
27 )
28 .await?;
29 }
30 Ok(())
31 }
32
33 async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> {
34 Ok(())
36 }
37}