Skip to content

feat(db): detect modifications to existing columns and indexes #461

Description

@GaspardKirira

Summary

Extend the schema diff engine to detect changes to columns and indexes that already exist by name.

Current behavior

The current diff engine detects only additions and removals.

It does not detect changes to:

  • column types;
  • sizes;
  • nullability;
  • default values;
  • uniqueness;
  • auto-increment behavior;
  • primary-key state;
  • index columns;
  • index uniqueness.

Expected behavior

The diff engine must produce explicit alteration operations when supported schema properties change.

Unsafe or ambiguous changes must be reported instead of silently ignored.

Scope

  • Add column alteration operation types.
  • Add index replacement or alteration operation types.
  • Compare every supported column property.
  • Compare index column order and uniqueness.
  • Generate MySQL SQL for supported alterations.
  • Add SQLite handling or clear unsupported-operation diagnostics.
  • Generate inverse down operations.
  • Add diff and golden SQL tests.
  • Preserve the existing diff_or_throw() entry point.

Suggested files

  • modules/db/include/vix/db/mig/diff/Op.hpp
  • modules/db/src/mig/diff/Diff.cpp
  • modules/db/src/mig/sql/MySqlGenerator.cpp
  • modules/db/src/mig/sql/SQLiteGenerator.cpp
  • modules/db/tests/migration_diff_test.cpp

Acceptance criteria

  • Type changes are detected.
  • Nullability changes are detected.
  • Default-value changes are detected.
  • Index definition changes are detected.
  • Unchanged definitions produce no operation.
  • Unsupported unsafe changes fail clearly.
  • Down migrations restore the previous definition.
  • Operation ordering remains deterministic.
  • Existing public diff entry points remain compatible.

Non-goals

This issue does not include:

  • automatic column rename detection;
  • automatic data conversion;
  • foreign-key alteration;
  • ORM model comparison.

Suggested labels

  • scope:db
  • type:feature
  • tests
  • help wanted
  • status:accepted

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededscope:dbDatabase driversstatus:acceptedApproved, plannedtestsTests, CI coverage and validationtype:featureNew functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions