Prisma · infra · fg-0295

Prisma through PgBouncer or the Supabase pooler fails with 'prepared statement "s0" already exists'

If you see prepared statement "s0" already exists, the cause and the fix for Prisma are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
prepared statement "s0" already existsprisma migrate deploy fails or hangs when the CLI URL points at the pooler port 6543
Cause
Transaction-mode poolers do not keep named prepared statements on one session, and Prisma Migrate needs a single direct connection that poolers do not provide.
Fix
Give the CLI a direct connection and the client the pooled one. On Prisma 6, add pgbouncer=true to the pooled URL only for PgBouncer before 1.21 and configure max_prepared_statements on 1.21 and later; the Prisma 7 docs do not say whether @prisma/adapter-pg reads pgbouncer=true.
Apply
// prisma.config.ts: migrations use the direct URL datasource: { url: process.env.DIRECT_URL }, // runtime uses the pooled URL const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
Affected
Prisma ORM 6 and 7 with transaction-mode PgBouncer or Supavisor, as of October 2026; vendor policy, re-check by 2026-12-15
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun