Context
Runtime uses the Supabase transaction pooler (6543, PgBouncer), which cannot run prisma migrate; migrating meant a human swapping DATABASE_URL. Render's autoDeploy shipped code before anyone ran migrations, and the seed minted shared-password demo accounts whenever NODE_ENV !== 'production' — including an unset NODE_ENV against staging.
Decision
schema.prismagetsdirectUrl = env("DIRECT_URL")(session pooler 5432); the app stays onDATABASE_URL.db:*scripts run the CLI throughscripts/prisma-cli.ts: unsetDIRECT_URLfalls back toDATABASE_URLunless that URL is pooled, which is refused; when both are set they must name the same database (Supabase project ref or host, plus db name; port and query ignored), so a stale localhostDIRECT_URLcannot silently absorb a staging migration. It prints the target host, never credentials. Compose sets it formigrate. This supersedes ADR-0009's bareprisma migrate deploycommand.- Render
autoDeploy: false(free plan: nopreDeployCommand)..github/workflows/deploy.ymlruns after CI passes onmain:migrate deploywith secretsDATABASE_URL/DIRECT_URL, then POSTsRENDER_DEPLOY_HOOK_URL&ref=<sha>, pinned to the migrated commit. The roll is skipped only if a newermaincommit already passed CI (its run owns the roll); otherwise this commit rolls, so a red newer commit cannot strand applied migrations.workflow_dispatchmust find green CI for its SHA before migrating. Serialized, never cancelled mid-run. - Ordering contract: schema first, code second. Old code runs on the new schema until the roll finishes, so migrations are expand-then-contract.
- Demo accounts only when
NODE_ENV === 'development'exactly and no DB URL points atsupabase.co/supabase.com(prisma/seed-guard.ts, tested). Admin seeding is unchanged. The seed imports the package'ssrc/indexbarrel.
Alternatives considered
- Migrate on container boot — every instance races the lock and a bad migration crash-loops the service.
- Render
preDeployCommand— paid plans only; revisit if the plan changes.
Consequences
Three GitHub secrets must exist before main deploys; a missing one fails the Deploy run loudly. A Render dashboard "Manual Deploy" bypasses the contract.