@@ -417,21 +417,17 @@ fn find_non_nullable_fk_add_columns(
417417 if let Some ( model) = current_models
418418 . iter ( )
419419 . find ( |m| m. name . as_str ( ) == table. as_str ( ) )
420- {
421- if let Some ( col_def) = model
420+ && let Some ( col_def) = model
422421 . columns
423422 . iter ( )
424423 . find ( |c| c. name . as_str ( ) == col_name. as_str ( ) )
425- {
426- if !col_def. nullable && col_def. default . is_none ( ) {
424+ && !col_def. nullable && col_def. default . is_none ( ) {
427425 result. push ( RecreateTableRequired {
428426 table : table. clone ( ) ,
429427 column : col_name. clone ( ) ,
430428 reason : RecreateReason :: AddFkToExistingColumn ,
431429 } ) ;
432430 }
433- }
434- }
435431 }
436432 }
437433 }
@@ -507,7 +503,7 @@ fn rewrite_plan_for_recreation(
507503 | MigrationAction :: RemoveConstraint { table, .. } => Some ( table. as_str ( ) ) ,
508504 _ => None ,
509505 } ;
510- table. map_or ( true , |t| !tables_to_recreate. contains ( t) )
506+ table. is_none_or ( |t| !tables_to_recreate. contains ( t) )
511507 } ) ;
512508
513509 // Add DeleteTable + CreateTable for each recreated table
@@ -1092,8 +1088,12 @@ mod tests {
10921088 rewrite_plan_for_recreation ( & mut plan, & recreate, & models) ;
10931089
10941090 assert_eq ! ( plan. actions. len( ) , 2 ) ;
1095- assert ! ( matches!( & plan. actions[ 0 ] , MigrationAction :: DeleteTable { table } if table == "post" ) ) ;
1096- assert ! ( matches!( & plan. actions[ 1 ] , MigrationAction :: CreateTable { table, .. } if table == "post" ) ) ;
1091+ assert ! (
1092+ matches!( & plan. actions[ 0 ] , MigrationAction :: DeleteTable { table } if table == "post" )
1093+ ) ;
1094+ assert ! (
1095+ matches!( & plan. actions[ 1 ] , MigrationAction :: CreateTable { table, .. } if table == "post" )
1096+ ) ;
10971097 }
10981098
10991099 #[ test]
0 commit comments