Skip to content

fix(db): make migration 000027 idempotent (savings_snapshots_pk) #246

Description

@cristim

Integration tests that spin up a fresh Postgres via testcontainers-go can't run the full migration set — migration 000027 (savings_snapshots_pk) tries to ADD PRIMARY KEY that migration 000018 already added, failing with 'multiple primary keys for table'.

Production DBs aren't affected because they were already in the 'duplicate rows needing dedup' state that 000027 was written to fix.

Fix: make the ADD CONSTRAINT idempotent (e.g. DROP CONSTRAINT IF EXISTS first, or wrap in a conditional PL/pgSQL block) without changing the behaviour on already-migrated databases.

Commit 2d8f1e2 currently works around it by bypassing migrations entirely for the cache integration test.

Activity

  1. added 2 commits that reference this issue on May 22, 2026
    ad3f216
    105338d
  2. cristim commented on May 28, 2026

    @cristim
    MemberAuthor

    Verified shipped: merge commit 105338d (PR #540) is in origin/feat/multicloud-web-frontend (compare API: feat is ahead of 105338d). PR #540 body says "Closes #246" and adds a regression test pinning that migration 000027 (savings_snapshots_pk) is idempotent across replays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions