Skip to content

test(db): add migration diff and MySQL generator golden tests #441

Description

@GaspardKirira

Summary

Add automated tests for the schema diff engine and MySQL migration SQL generator.

Generated migration operations and SQL must be deterministic and reversible.

Current behavior

The diff engine currently supports:

  • table creation;
  • table removal;
  • column addition;
  • column removal;
  • index creation;
  • index removal.

The MySQL generator produces up and down SQL scripts for these operations.

No automated tests currently protect the generated output.

Expected behavior

Tests must compare migration operations and generated SQL against reviewed expected output.

Scope

  • Test an empty diff.
  • Test table creation.
  • Test table removal.
  • Test column addition.
  • Test column removal.
  • Test index creation.
  • Test index removal.
  • Test multiple operations in one diff.
  • Test MySQL type generation.
  • Test identifier quoting.
  • Test nullable and non-null columns.
  • Test primary keys.
  • Test auto-increment columns.
  • Test unique columns.
  • Test default values.
  • Test generated down migrations.
  • Preserve the existing public DB API.

Suggested files

  • modules/db/tests/migration_diff_test.cpp
  • modules/db/tests/mysql_generator_test.cpp
  • modules/db/tests/golden/...

Acceptance criteria

  • Every currently supported operation has test coverage.
  • Generated up SQL is compared against expected output.
  • Generated down SQL is compared against expected output.
  • Down operations are emitted in reverse order.
  • Test expectations are readable and easy to review.
  • Repeated runs produce identical output.
  • Existing public APIs remain unchanged.

Non-goals

This issue does not include:

  • altered-column detection;
  • renamed-column detection;
  • SQLite SQL generation;
  • PostgreSQL SQL generation;
  • foreign-key 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