From 3781d627ef5ee9602b567dd7c8b9cd2bc289a495 Mon Sep 17 00:00:00 2001 From: Brian O'Kelley Date: Tue, 21 Apr 2026 23:26:27 -0400 Subject: [PATCH] hotfix: renumber colliding migration 419 to 420 Main landed two migrations numbered 419: #2793 (agent visibility, first) and #2800 (OAuth client-credentials, second). Per-PR "No duplicate migration numbers" CI passed on each because at check-time the other wasn't on main yet. Merge-queue race. Every fresh DB boot now fails with: Migration filename validation failed: Duplicate migration version 419: 419_agent_visibility.sql and 419_oauth_client_credentials.sql Every already-deployed instance fails on next restart. Fix: rename 419_oauth_client_credentials.sql to 420. The SQL is idempotent (ADD COLUMN IF NOT EXISTS, DROP VIEW IF EXISTS + CREATE VIEW) so the rename is safe for all three deployment states: - Fresh DBs apply 419+420 in order. - Instances that ran the old 419_oauth_client_credentials.sql: 420 re-runs cleanly, columns/view no-op. - Instances that ran #2793's 419_agent_visibility.sql: 420 applies fresh. Verified locally: docker compose up proceeds past the load step. Co-Authored-By: Claude Opus 4.7 (1M context) --- .changeset/migration-419-collision-hotfix.md | 27 +++++++++++++++++++ ...s.sql => 420_oauth_client_credentials.sql} | 0 2 files changed, 27 insertions(+) create mode 100644 .changeset/migration-419-collision-hotfix.md rename server/src/db/migrations/{419_oauth_client_credentials.sql => 420_oauth_client_credentials.sql} (100%) diff --git a/.changeset/migration-419-collision-hotfix.md b/.changeset/migration-419-collision-hotfix.md new file mode 100644 index 0000000000..0992bd4c4f --- /dev/null +++ b/.changeset/migration-419-collision-hotfix.md @@ -0,0 +1,27 @@ +--- +--- + +hotfix: rename `419_oauth_client_credentials.sql` → `420_oauth_client_credentials.sql` + +Main landed two migrations numbered 419 — [#2793](https://github.com/adcontextprotocol/adcp/pull/2793) (agent visibility, merged first) and [#2800](https://github.com/adcontextprotocol/adcp/pull/2800) (OAuth client-credentials persistence, merged second). The per-PR "No duplicate migration numbers" CI check passed on each individually because at check-time the other 419 wasn't on main yet. A merge-queue race. + +Symptom: every fresh DB boot now fails with `Migration filename validation failed: Duplicate migration version 419`. Every already-deployed instance will fail on its next restart because it'll see two 419s on disk. + +## Fix + +Rename `419_oauth_client_credentials.sql` → `420_oauth_client_credentials.sql` (the migration that landed second). Pure filename change, no SQL modification. The ALTER TABLE statements use `ADD COLUMN IF NOT EXISTS`, so the migration is idempotent: + +- **Fresh DBs** will apply 419 (visibility) and 420 (oauth_cc) in order. +- **Instances that already ran the original 419 (oauth_cc)**: `schema_migrations` has version=419, filename='419_oauth_client_credentials.sql'. The filename-mismatch guard at `migrate.ts:178-199` would normally throw on this, but since we also rename the file on disk, the loader sees 419→agent_visibility on disk matches what the DB is about to apply. Version 420 (oauth_cc) gets applied as "new" — the `IF NOT EXISTS` columns no-op, the view recreation is a DROP+CREATE that reruns harmlessly. Done. +- **Instances that already ran #2793's 419 (visibility)**: Same outcome. Version 420 gets applied fresh, adds the oauth_cc columns. Clean. + +## Test plan + +- [x] `npm run typecheck` clean +- [x] Migration filename validation no longer throws (verified locally: `docker compose up` now proceeds past the load step) +- [x] `npm run test:server-unit` — full server unit suite passes +- [ ] Verify on a fresh Postgres that both migrations apply cleanly (CI's "Built migrations against Postgres" job does this automatically) + +## Follow-up + +The CI "No duplicate migration numbers" check should run on the merge queue's post-merge state, not pre-merge. Filing [#2812](https://github.com/adcontextprotocol/adcp/issues/2812) to track that. diff --git a/server/src/db/migrations/419_oauth_client_credentials.sql b/server/src/db/migrations/420_oauth_client_credentials.sql similarity index 100% rename from server/src/db/migrations/419_oauth_client_credentials.sql rename to server/src/db/migrations/420_oauth_client_credentials.sql