Skip to content

test: migrator FK constraint cleanup is non-idempotent — fails on MySQL/H2/SQL Server reruns #2664

Description

@bpamiri

Describe the bug

wheels.tests.specs.migrator.migratorSpec (the migrateTo :: uses specified versions table name suite) creates a foreign key constraint named fk_wheels_level but does not drop it on teardown. When the spec runs against the same database a second time (which happens inside one matrix job because the spec executes the migration up and re-executes it), the constraint creation errors:

Evidence

Compat-matrix run #25837380625 (2026-05-13).

Expected behavior

The migrator spec should run repeatedly within the same test session without leaving constraints behind. Either:

  1. Drop the constraint in the suite's afterEach / afterAll, or
  2. Use a uniquely-named constraint per spec run (timestamp suffix), or
  3. Use the down-migration to clean up after the up.

Root cause

Pure test-cleanup bug. The migrator spec uses a hardcoded constraint name and re-runs without teardown. Cockroach/Postgres silently tolerate the redefinition; MySQL/H2/SQL Server/Oracle correctly reject it.

Suggested fix shape

Add a teardown step that drops fk_wheels_level (and any other named constraints created in the spec) before each run, or rewrite to use a per-test-run unique name. Low effort.

Additional context

Related: #2649, #2663

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions