Prisma · infra · fg-0295
Prisma through PgBouncer or the Supabase pooler fails with 'prepared statement "s0" already exists'
prepared statement "s0" already exists
Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100
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 })Affects: Prisma ORM 6 and 7 with transaction-mode PgBouncer or Supavisor, as of October 2026; vendor policy, re-check by 2026-12-15
Sources
- https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/databases-connections/pgbouncer
- https://github.com/prisma/orm/issues/11643
- https://supabase.com/docs/guides/database/connecting-to-postgres
Have your agent know this before it fails
claude mcp add --transport http footgun https://getfootgun.com/api/mcp