@@ -386,11 +386,17 @@ fn auto_migrate_table<'def>(plan: &mut AutoMigratePlan<'def>, old: &'def TableDe
386386 } )
387387 . map ( |col_diff| -> Result < _ > {
388388 match col_diff {
389- Diff :: Add { new } => Err ( AutoMigrateError :: AddColumn {
390- table : new. table_name . clone ( ) ,
391- column : new. name . clone ( ) ,
389+ Diff :: Add { new } => {
390+ if new. col_id >= old. columns . len ( ) . into ( ) {
391+ Ok ( Any ( true ) ) // column type is inherently new as we're creating a new one
392+ } else {
393+ Err ( AutoMigrateError :: AddColumn {
394+ table : new. table_name . clone ( ) ,
395+ column : new. name . clone ( ) ,
396+ }
397+ . into ( ) )
398+ }
392399 }
393- . into ( ) ) ,
394400 Diff :: Remove { old } => Err ( AutoMigrateError :: RemoveColumn {
395401 table : old. table_name . clone ( ) ,
396402 column : old. name . clone ( ) ,
@@ -423,9 +429,9 @@ fn auto_migrate_table<'def>(plan: &mut AutoMigratePlan<'def>, old: &'def TableDe
423429 } )
424430 . collect_all_errors :: < Any > ( ) ;
425431
426- let ( ( ) , Any ( row_type_changed ) ) = ( type_ok, columns_ok) . combine_errors ( ) ?;
432+ let ( ( ) , Any ( column_type_changed ) ) = ( type_ok, columns_ok) . combine_errors ( ) ?;
427433
428- if row_type_changed {
434+ if column_type_changed {
429435 plan. steps . push ( AutoMigrateStep :: ChangeColumns ( key) ) ;
430436 }
431437
0 commit comments