ARTICLE AD BOX
I am using Prisma 7.4.0 with Supabase and I'm facing a blocking issue with migrations.
When I run npx prisma migrate dev, the process hangs indefinitely at this point:
Loaded Prisma config from prisma.config.ts. Prisma schema loaded from prisma\schema.prisma. Datasource "db": PostgreSQL database "postgres", schema "public" at "aws-1-us-east-1.pooler.supabase.com:6543"The issue is that Prisma is trying to migrate through the Transaction Pooler (port 6543), which is known to cause hangs during migrations because it doesn't support the required advisory locks.
In my .env file, I have both URLs:
# Pooler connection for the App DATABASE_URL="postgresql://user:[email protected]:6543/postgres?pgbouncer=true" # Direct connection for Migrations DIRECT_URL="postgresql://user:[email protected]:5432/postgres"However, Prisma 7 introduces prisma.config.ts, and the defineConfig helper does not seem to accept a directUrl property for the CLI to use during migrations. My config looks like this:
import "dotenv/config"; import { defineConfig } from "prisma/config"; export default defineConfig({ schema: "prisma/schema.prisma", datasource: { url: process.env["DATABASE_URL"], // Only accepts one URL }, });If I try to add directUrl to the datasource object, I get a TypeScript error: Object literal may only specify known properties, and 'directUrl' does not exist in type '{ url?: string; shadowDatabaseUrl?: string; }'..
What I've tried:
Removing prisma.config.ts to rely on schema.prisma alone, but Prisma 7 seems to enforce or prefer the new config file for certain environments.
Manually overriding the environment variable in the terminal: $env:DATABASE_URL=$env:DIRECT_URL; npx prisma migrate dev, but the CLI still picks up the pooler URL from the config file.
Question: How can I properly configure Prisma 7 to use DIRECT_URL for migrations and DATABASE_URL for the runtime client without resorting to hardcoding the direct URL in the config file every time I need to migrate? Is there a supported way to define the migration-specific URL in prisma.config.ts?
