Repository navigation
fix(cross-service): make the nonce migration idempotent (rebased on main) - #518
Merged
silvertakana merged 4 commits intoSep 15, 2026
Merged
Conversation
The 20260915170000 migration created the table and its indexes unconditionally, so prisma migrate deploy failed with 42P07 whenever the table already existed, which is the documented dev flow: pnpm dev runs prisma db push from the schema first. docker-entrypoint.sh auto-baselines only on P3005, so that failure exits the container instead of resolving. IF NOT EXISTS on all three statements makes a re-run a no-op. Version 2.68.6, above the sibling branch fix/billing-lock-paths-and-migrate at 2.68.5.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…ce-migration-idempotent-rebased
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replacement for #513, which supersedes it. The original PR is left open and untouched.
The original branch held four commits, but three of them are already in
mainthrough #505 (4d5c1453,84a81f23,2466d8be) and onlycfc6e864is unique to it. This branch therefore carries exactly that one commit, replayed onto currentmain(c7db26fe). Re-applying the three older commits would have made things worse, not better:mainalready hasconst result = await verifyCrossServiceSignature(...), while4d5c1453carries it un-awaited, so cherry-picking it would regressmain.An in-place update of #513 is not possible without a force-push, for the same reason as #511: the branch is not patch-equivalent to a
mainthat has since advanced by squash commits.What it fixes
The database migration that adds the replay-protection table could not be run twice: a second attempt failed instead of doing nothing. It is now safe to re-run, so a deployment that was interrupted partway through the migration can simply try again.
Why it matters
Migrations get re-run in practice (a failed deploy, a retried pipeline, a fresh environment). A migration that cannot be re-run turns a small interruption into a manual database cleanup.
How the commits map
cfc6e864make the nonce migration idempotent88fd953e5f99e550chore(release): bump version to 2.68.13(mainis at 2.68.9)The old note "builds on #505 and must not merge before it" is obsolete: #505 is already in
main, andmain's cross-service code files (middleware.ts,verify.ts,nonceCache.ts,types.ts,service/tier/route.ts) are byte-identical to what the original branch carried.Files changed (2 files, +18 / -4)
package.jsonprisma/migrations/20260915170000_add_cross_service_nonce/migration.sqlCREATE TABLE IF NOT EXISTSandCREATE INDEX IF NOT EXISTSmake a secondprisma migrate deploya no-op rather than a 42P07 failure.Gate results (local, this branch)
pnpm testpnpm exec tsc --noEmitpnpm lint+pnpm check:demo-gatespnpm buildnode tests/migration/run.mjs, the workflow that triggers onprisma/migrations/**)On gitleaks: no new allowlist entries were added here. The flagged
generic-api-keyfinding traces to commit4d5c1453introducing a dummy 32-character fixture secret, which #505 already fixed onmainby rotating the fixture and adding the fingerprint to.gitleaksignore. This branch does not contain4d5c1453at all, so the finding cannot fire from it.A green check here still does not prove the migration re-runs cleanly against a real production database; the local run above exercises a throwaway Postgres 16 instance built the same way the CI workflow builds it.