Skip to content

feat(db): track and roll back code-based migrations #464

Description

@GaspardKirira

Summary

Turn MigrationsRunner into a tracked and reversible code-migration runner.

Current behavior

MigrationsRunner stores raw migration pointers and executes every registered migration through up().

It does not:

  • inspect migration identifiers;
  • persist applied state;
  • skip applied migrations;
  • validate duplicate identifiers;
  • execute down();
  • support rollback.

Expected behavior

Code-based migrations must provide deterministic ordering and persistent applied-state tracking similar to file migrations.

Scope

  • Validate migration identifiers.
  • Sort or explicitly preserve documented ordering.
  • Create or reuse a migration tracking table.
  • Skip migrations already applied.
  • Apply pending migrations transactionally.
  • Add rollback support.
  • Detect duplicate migration identifiers.
  • Define ownership expectations for registered migration objects.
  • Add SQLite integration tests.
  • Preserve current migration class signatures where possible.

Suggested files

  • modules/db/include/vix/db/mig/MigrationsRunner.hpp
  • modules/db/src/mig/MigrationsRunner.cpp
  • modules/db/tests/code_migrations_runner_test.cpp

Acceptance criteria

  • Applied migrations are persisted.
  • Applied migrations are not executed twice.
  • Duplicate IDs are rejected.
  • Rollback invokes the correct down() method.
  • Failed migrations are not marked as applied.
  • Migration ordering is documented and tested.
  • Existing migration implementations remain source-compatible where possible.

Non-goals

This issue does not include:

  • automatic C++ migration generation;
  • ORM model migrations;
  • distributed migration coordination;
  • schema introspection.

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