risingwave_meta_model_migration/
m20250907_000000_source_splits.rs1use sea_orm_migration::prelude::*;
2
3use crate::drop_tables;
4use crate::utils::ColumnDefExt;
5
6#[derive(DeriveMigrationName)]
7pub struct Migration;
8
9#[async_trait::async_trait]
10impl MigrationTrait for Migration {
11 async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
12 manager
13 .create_table(
14 Table::create()
15 .table(SourceSplits::Table)
16 .col(
17 ColumnDef::new(SourceSplits::SourceId)
18 .integer()
19 .primary_key()
20 .not_null(),
21 )
22 .col(ColumnDef::new(SourceSplits::Splits).rw_binary(manager))
23 .foreign_key(
24 &mut ForeignKey::create()
25 .name("FK_source_splits_source_oid")
26 .from(SourceSplits::Table, SourceSplits::SourceId)
27 .to(Source::Table, Source::SourceId)
28 .on_delete(ForeignKeyAction::Cascade)
29 .to_owned(),
30 )
31 .to_owned(),
32 )
33 .await?;
34
35 Ok(())
36 }
37
38 async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
39 drop_tables!(manager, SourceSplits);
40 Ok(())
41 }
42}
43
44#[derive(DeriveIden)]
45enum SourceSplits {
46 Table,
47 SourceId,
48 Splits,
49}
50
51#[derive(DeriveIden)]
52enum Source {
53 Table,
54 SourceId,
55}