Context
ADR-0031 runs prisma migrate deploy in CI before it triggers the Render deploy, and the container never migrated on its own. On 2026-11-21 CircleCI ran out of credits (refill on 2026-12-07) and GitHub Actions was already out of minutes, so nothing could deploy: six merged features with five additive migrations sat undeployed. A one-off Render job could have run the migration, but Render's free plan refuses jobs. The session connection string lives only in CI's secret store.
Decision
- The API image ships the Prisma CLI (pinned to the repo's version, engines downloaded at build time) plus
schema.prismaand the migrations folder, under/db/prisma. infra/runtime/supervise.mjsrunsprisma migrate deploybefore it starts the API and the worker whenMIGRATE_ON_BOOTis on (the image default; Compose turns it off).- The migration connection is
DIRECT_URLwhen set, otherwiseDATABASE_URLwith the Supabase transaction-pooler port 6543 switched to the session-pooler port 5432 and the pooling parameters removed. Only the port and query parameters change; the script never logs the URL. - If migration fails or times out (
MIGRATE_TIMEOUT_MS, default 180 s), nothing starts and the container exits non-zero. The health check fails and Render keeps the previous deploy live, so new code never serves an old schema. - CI keeps running
migrate deployfirst. Both paths are idempotent andmigrate deploytakes Prisma's advisory lock, so they cannot apply the same migration twice.
Consequences
- A deploy can be triggered from the Render deploy hook or API alone, without CI.
- Boot is a few seconds slower when nothing is pending; the health-check start period is now 90 s to cover a migration.
- Migrations still have to be additive and safe to run while the previous version serves traffic, as ADR-0031 already requires.