diff --git a/prisma/prisma.config.ts b/prisma/prisma.config.ts index 2dc43ddc8..4cace540e 100644 --- a/prisma/prisma.config.ts +++ b/prisma/prisma.config.ts @@ -1,11 +1,21 @@ -import 'dotenv/config'; +import 'dotenv/config' +import { defineConfig } from 'prisma/config' -export default { +// Prisma CLI (migrate, db push, etc.) talks to the DB through this URL. +// For Supabase deployments this MUST be the *direct* (non-pooled) URL — +// the pgBouncer session/transaction pooler cannot open shadow databases. +// The runtime Prisma client uses DATABASE_URL via the PrismaPg adapter +// in packages/shared/src/utils/database/prismaClient.ts. +// +// We fall back to DATABASE_URL when DIRECT_URL is unset so existing local +// docker-compose dev (single Postgres, one URL) keeps working unchanged. +// Supabase deployments should set both. +export default defineConfig({ schema: 'schema.prisma', migrations: { path: 'migrations', }, datasource: { - url: process.env.DATABASE_URL ?? '', + url: process.env.DIRECT_URL ?? process.env.DATABASE_URL ?? '', }, -}; +})