Home

boring / v2

publicBoring-Software-Inc/v2
Overview Code History Branches Pull requestsIssuesInsights Campfire Docs
main
HomeOverview Code PRsIssues

feat(deploy): PlanetScale pooled/direct split + verify gate (unit 3)

4 months ago

36a43e7
Authored
grim7/13/2026, 11:45:35 PM
PlanetScale's pooler drops the session a LISTEN needs, so the app uses two
URLs: DATABASE_URL (pooled) for transactional/query work + pg-boss, and
DATABASE_URL_DIRECT (direct/session) for LISTEN/NOTIFY only. New
createDirectPool() falls back to DATABASE_URL when direct is unset, so local
dev is unchanged. The api SSE stream holds its LISTEN on the direct pool; the
worker's pool (pg_notify only) is the direct pool, queries + pg-boss stay
pooled.

New 'bun run verify:planetscale' gates cutover, exiting non-zero on failure:
- A. transaction affinity on the pooled URL, PROVEN BY ROLLBACK: runs the real
  ingest (INSERT event + pg-boss enqueue in one tx), confirms atomic commit,
  then rolls back a second attempt and asserts neither row nor job survived.
- B. LISTEN/NOTIFY on the direct URL, payload asserted within 7s. If B fails
  the script STOPS — no polling fallback (that is a spec decision, not ours).

Verified: exits 0 against compose Postgres, exits 1 when DATABASE_URL_DIRECT is
unset; 52 api/db/worker tests pass; typecheck + biome + boundaries clean.

Parent6316fbe

14 files changed
  • .env.example+7−1
  • DECISIONS.md+30−0
  • DEPLOY.md+56−5
  • all-summaries.md+20−0
  • apps/api/src/env.ts+6−0
  • apps/api/src/index.ts+3−1
  • apps/api/src/routes/stream.ts+2−2
  • apps/api/src/stream.integration.test.ts+2−0
apps/api/src/webhooks.integration.test.ts
+1
−0
  • apps/worker/src/index.ts+12−3
  • package.json+2−1
  • packages/db/src/client.ts+18−0
  • packages/db/src/index.ts+1−1
  • scripts/verify-planetscale.ts+232−0