Skip to content

bug: duplicate SQL migration version blocks Core CI and database migration #4427

Description

@jayzhudev

Version

main

Describe the bug.

Two migrations under crates/api-db/migrations use version 20260722120000:

20260722120000_preserve_machine_ipv6_loopback.sql
20260722120000_bmc_suppressions.sql

SQLx identifies migrations by numeric version and stores that version as the primary key in _sqlx_migrations. Applying both migrations fails because the second migration attempts to record an existing version.

This blocks test-release-container-services on main and dependent PRs. Migration versions should be unique, and both migrations should apply successfully to a fresh database.

Proposed fix:

  1. Rename the newer migration to an unused version, for example:

    20260722120001_bmc_suppressions.sql
    
  2. Confirm persistent databases have the earlier migration associated with version 20260722120000:

    SELECT version, description
    FROM _sqlx_migrations
    WHERE version = 20260722120000;
  3. Add duplicate migration-version validation so future collisions fail with a focused diagnostic.

Acceptance criteria:

  • Every migration in crates/api-db/migrations has a unique version.
  • Fresh-database migration succeeds.
  • Existing databases containing the earlier migration upgrade successfully.
  • test-release-container-services passes on main.

Minimum reproducible example

find crates/api-db/migrations \
  -maxdepth 1 \
  -name '20260722120000_*.sql' \
  -print

cargo make test-release-container-services

Relevant log output

duplicate key value violates unique constraint "_sqlx_migrations_pkey"
Key (version)=(20260722120000) already exists

Other/Misc.

No response

Code of Conduct

  • I agree to follow NVIDIA Infra Controller's Code of Conduct
  • I have searched the open bugs and have found no duplicates for this bug report

Metadata

Metadata

Assignees

Labels

bugA defect in existing software (deprecated - use issue type, but it's needed for reporting now)

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions