File tree 3 files changed +20
-0
lines changed
3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -519,6 +519,14 @@ impl MigrationTrait for Migration {
519
519
. to ( Connection :: Table , Connection :: ConnectionId )
520
520
. to_owned ( ) ,
521
521
)
522
+ . foreign_key (
523
+ & mut ForeignKey :: create ( )
524
+ . name ( "FK_source_optional_associated_table_id" )
525
+ . from ( Source :: Table , Source :: OptionalAssociatedTableId )
526
+ . to ( Object :: Table , Object :: Oid )
527
+ . on_delete ( ForeignKeyAction :: Cascade )
528
+ . to_owned ( ) ,
529
+ )
522
530
. to_owned ( ) ,
523
531
)
524
532
. await ?;
Original file line number Diff line number Diff line change @@ -468,6 +468,7 @@ impl CatalogController {
468
468
. clone ( )
469
469
. into_iter ( )
470
470
. chain ( state_table_ids. clone ( ) . into_iter ( ) )
471
+ . chain ( associated_source_ids. clone ( ) . into_iter ( ) )
471
472
. collect ( ) ;
472
473
473
474
let res = Object :: delete_many ( )
Original file line number Diff line number Diff line change @@ -401,13 +401,24 @@ impl CatalogController {
401
401
. all ( & txn)
402
402
. await ?;
403
403
404
+ let associated_source_id: Option < SourceId > = Table :: find_by_id ( job_id)
405
+ . select_only ( )
406
+ . column ( table:: Column :: OptionalAssociatedSourceId )
407
+ . filter ( table:: Column :: OptionalAssociatedSourceId . is_not_null ( ) )
408
+ . into_tuple ( )
409
+ . one ( & txn)
410
+ . await ?;
411
+
404
412
Object :: delete_by_id ( job_id) . exec ( & txn) . await ?;
405
413
if !internal_table_ids. is_empty ( ) {
406
414
Object :: delete_many ( )
407
415
. filter ( object:: Column :: Oid . is_in ( internal_table_ids) )
408
416
. exec ( & txn)
409
417
. await ?;
410
418
}
419
+ if let Some ( source_id) = associated_source_id {
420
+ Object :: delete_by_id ( source_id) . exec ( & txn) . await ?;
421
+ }
411
422
txn. commit ( ) . await ?;
412
423
413
424
Ok ( true )
You can’t perform that action at this time.
0 commit comments