FORGE-85: unique index on deployment_events.seq #712
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
gmackie/ForgeGraph!712
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "FORGE-85-seq-unique-index"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part 7a of FORGE-85 (D1 Phase 2, parent FORGE-69). Stacked on #709. Adds a migration (renumbered from 0116 to 0121: 0117-0120 are taken or reserved on main).
packages/db/drizzle/0121_deployment_event_seq_unique.sql:CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS deployment_event_seq_unique_idx ON deployment_events (seq), with the INVALID-index check documented. Additive, online, idempotent. Schema declares the same index.count(distinct seq) = count(*), max seq 17193 = sequence last_value, about 318 inserts/day.appendDeploymentEventtries the serial default first and, only after a seq collision, falls back to themax(seq) + 1insert that #713 makes primary. That makes this release safe before the index exists (no collisions possible), during the cutover overlap with max + 1 writers, and as a rollback target afterwards, when the sequence lags behind max(seq).Rollout: after merge, apply 0121 to production with
fg db migrate --file packages/db/drizzle/0121_deployment_event_seq_unique.sql, verifyindisvalid, and confirm the next deploy passes the drift gate before merging 7b.Verification
deployment-events-seq-index.database.test.ts: a duplicate seq is rejected; an append succeeds with the sequence 50 behind max(seq). The second case runs on real Postgres only (CI's lane; PG16 locally), because the PGlite wire emulation drops RETURNING rows for an insert that follows a failed one.🤖 Generated with Claude Code
a6f1b3a6271eebcb60e5d820ff4b459ce4037975