@@ -386,11 +386,17 @@ fn auto_migrate_table<'def>(plan: &mut AutoMigratePlan<'def>, old: &'def TableDe
386
386
} )
387
387
. map ( |col_diff| -> Result < _ > {
388
388
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
+ }
392
399
}
393
- . into ( ) ) ,
394
400
Diff :: Remove { old } => Err ( AutoMigrateError :: RemoveColumn {
395
401
table : old. table_name . clone ( ) ,
396
402
column : old. name . clone ( ) ,
@@ -423,9 +429,9 @@ fn auto_migrate_table<'def>(plan: &mut AutoMigratePlan<'def>, old: &'def TableDe
423
429
} )
424
430
. collect_all_errors :: < Any > ( ) ;
425
431
426
- let ( ( ) , Any ( row_type_changed ) ) = ( type_ok, columns_ok) . combine_errors ( ) ?;
432
+ let ( ( ) , Any ( column_type_changed ) ) = ( type_ok, columns_ok) . combine_errors ( ) ?;
427
433
428
- if row_type_changed {
434
+ if column_type_changed {
429
435
plan. steps . push ( AutoMigrateStep :: ChangeColumns ( key) ) ;
430
436
}
431
437
0 commit comments