Skip to main content

classify_schema_update

Function classify_schema_update 

Source
pub fn classify_schema_update(
    old_fields: &[FieldDef],
    old_indexes: &[IndexDef],
    new_fields: &[FieldDef],
    new_indexes: &[IndexDef],
) -> Result<SchemaChange, DbError>
Expand description

Classify a schema update from (old_fields, old_indexes) to (new_fields, new_indexes).

Policy (v0.9.0, conservative):

  • Existing fields must remain present and type-compatible.
  • Enum fields may add variants (superset) but may not remove variants.
  • Constraints must be identical for existing fields (tightening is treated as breaking).
  • New fields are Safe only if they are top-level-absent-compatible (Optional); otherwise NeedsMigration.
  • Existing indexes must remain unchanged; adding indexes is Safe for NonUnique and NeedsMigration for Unique.