Skip to content

feat(db): add composite primary-key generation #468

Description

@GaspardKirira

Summary

Support tables whose primary key contains more than one column.

Current behavior

Columns contain an individual primary_key boolean.

The MySQL generator stops after finding the first primary-key column and emits only that column in the table primary key.

Expected behavior

All columns marked as part of the primary key must be emitted in declaration order.

Invalid primary-key combinations must be rejected.

Scope

  • Generate composite primary keys.
  • Preserve column declaration order.
  • Validate that primary-key columns exist.
  • Validate auto-increment restrictions.
  • Add MySQL golden tests.
  • Add SQLite generator tests when available.
  • Preserve existing single-column primary-key behavior.
  • Preserve existing schema structures where possible.

Suggested files

  • modules/db/src/mig/sql/MySqlGenerator.cpp
  • modules/db/src/mig/sql/SQLiteGenerator.cpp
  • modules/db/tests/mysql_generator_test.cpp
  • modules/db/tests/schema_validation_test.cpp

Acceptance criteria

  • Two-column primary keys generate valid SQL.
  • Three-column primary keys generate valid SQL.
  • Column order is stable.
  • Single-column primary keys remain unchanged.
  • Invalid auto-increment combinations fail clearly.
  • Down migration behavior remains correct.
  • Existing public APIs remain compatible.

Non-goals

This issue does not include:

  • changing primary keys on existing tables;
  • ORM composite identifiers;
  • foreign keys;
  • generated key objects.

Suggested labels

  • scope:db
  • type:feature
  • tests
  • good first issue
  • status:ready

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersscope:dbDatabase driversstatus:readyIssue is fully specified and ready for implementationtestsTests, 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