Skip to content

test(db): add file migration runner integration tests #442

Description

@GaspardKirira

Summary

Add integration tests for vix::db::FileMigrationsRunner.

File migrations modify persistent schemas and migration history, so their ordering, checksums, transactions, and rollback behavior must be thoroughly validated.

Current behavior

The file migration runner:

  • scans .up.sql and .down.sql files;
  • sorts migrations by identifier;
  • calculates SHA-256 checksums;
  • creates a migration tracking table;
  • applies pending migrations;
  • rejects changed applied migrations;
  • rolls back the latest migrations.

These behaviors are not currently covered by automated tests.

Expected behavior

Tests must use temporary migration directories and temporary SQLite databases to validate the full migration lifecycle.

Scope

  • Test migration directory scanning.
  • Test deterministic migration ordering.
  • Test applying one migration.
  • Test applying multiple migrations.
  • Test skipping already applied migrations.
  • Test checksum storage.
  • Test rejection of modified applied migrations.
  • Test rollback of one migration.
  • Test rollback of multiple migrations.
  • Test missing down migration handling.
  • Test missing migration directory handling.
  • Test failed migration rollback.
  • Test custom migration table names.
  • Clean up all temporary files.
  • Preserve the existing public DB API.

Suggested files

  • modules/db/tests/file_migrations_runner_test.cpp
  • modules/db/tests/fixtures/migrations/...

Acceptance criteria

  • Tests run without an external database server.
  • Applied migrations are tracked correctly.
  • Pending migrations are applied exactly once.
  • Modified applied migrations are rejected.
  • Failed migrations do not remain marked as applied.
  • Rollback removes the migration tracking entry.
  • Rollback executes the matching down script.
  • Temporary files and databases are removed.
  • Existing public APIs remain unchanged.

Non-goals

This issue does not include:

  • replacing the SQL statement splitter;
  • adding migration status output;
  • code-based migration tracking;
  • SQLite migration generation.

Suggested labels

  • scope:db
  • type:ci
  • tests
  • help wanted
  • status:ready

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededscope:dbDatabase driversstatus:readyIssue is fully specified and ready for implementationtestsTests, CI coverage and validationtype:ciCI, tests, or tooling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions