diff --git a/crates/sats/src/layout.rs b/crates/sats/src/layout.rs index d784196e42b..c20b2420e3f 100644 --- a/crates/sats/src/layout.rs +++ b/crates/sats/src/layout.rs @@ -310,7 +310,7 @@ impl HasLayout for ProductTypeLayoutView<'_> { impl ProductTypeLayoutView<'_> { /// Can `self` be changed compatibly to `new`? fn is_compatible_with(self, new: Self) -> bool { - self.elements.len() == new.elements.len() + self.elements.len() <= new.elements.len() && self .elements .iter() diff --git a/crates/schema/src/auto_migrate.rs b/crates/schema/src/auto_migrate.rs index 3b84a3526c1..e9398500e06 100644 --- a/crates/schema/src/auto_migrate.rs +++ b/crates/schema/src/auto_migrate.rs @@ -386,11 +386,17 @@ fn auto_migrate_table<'def>(plan: &mut AutoMigratePlan<'def>, old: &'def TableDe }) .map(|col_diff| -> Result<_> { match col_diff { - Diff::Add { new } => Err(AutoMigrateError::AddColumn { - table: new.table_name.clone(), - column: new.name.clone(), + Diff::Add { new } => { + if new.col_id >= old.columns.len().into() { + Ok(Any(true)) // column type is inherently new as we're creating a new one + } else { + Err(AutoMigrateError::AddColumn { + table: new.table_name.clone(), + column: new.name.clone(), + } + .into()) + } } - .into()), Diff::Remove { old } => Err(AutoMigrateError::RemoveColumn { table: old.table_name.clone(), column: old.name.clone(), @@ -423,9 +429,9 @@ fn auto_migrate_table<'def>(plan: &mut AutoMigratePlan<'def>, old: &'def TableDe }) .collect_all_errors::(); - let ((), Any(row_type_changed)) = (type_ok, columns_ok).combine_errors()?; + let ((), Any(column_type_changed)) = (type_ok, columns_ok).combine_errors()?; - if row_type_changed { + if column_type_changed { plan.steps.push(AutoMigrateStep::ChangeColumns(key)); }