Skip to content

Fix Prisma migrations hanging on Vercel (direct DB connection)#2

Merged
Differ3nce merged 3 commits intomainfrom
fix/prisma-migrations-direct-url
Feb 25, 2026
Merged

Fix Prisma migrations hanging on Vercel (direct DB connection)#2
Differ3nce merged 3 commits intomainfrom
fix/prisma-migrations-direct-url

Conversation

@Differ3nce
Copy link
Copy Markdown
Owner

Summary

  • Adds directUrl to the Prisma datasource pointing to DIRECT_URL env var — this routes prisma migrate deploy through Supabase's direct connection (port 5432) instead of pgBouncer (port 6543), which does not support the advisory locks Prisma needs
  • Restores the vercel-build script so migrations run automatically on every Vercel deploy

Required action

Add DIRECT_URL to Vercel environment variables for all environments — same Supabase credentials as DATABASE_URL but with port 5432 and without ?pgbouncer=true.

Test plan

  • Preprod deployment runs prisma migrate deploy without hanging
  • Preprod webpage loads (tables now exist)
  • Prod deployment unaffected (tables already exist, migrate deploy is a no-op)

🤖 Generated with Claude Code

Supabase's pgBouncer (port 6543) doesn't support advisory locks required
by prisma migrate deploy. Add directUrl to use the direct connection (port
5432) for migrations while the app continues using the pooler for queries.
Also restore vercel-build script so migrations run automatically on deploy.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
platformengineerintoolkit Ready Ready Preview, Comment Feb 25, 2026 6:54pm

Prisma 7 removed url/directUrl from schema.prisma datasource blocks.
Migration URLs are now configured in prisma.config.ts instead.
Using DIRECT_URL (port 5432) here bypasses pgBouncer so advisory locks work.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
vercel-build was not being picked up by Vercel's Next.js preset.
Moving migrate deploy into the standard build script ensures it runs
on every deployment. It is idempotent so prod is unaffected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Differ3nce Differ3nce merged commit fa5cabc into main Feb 25, 2026
2 of 3 checks passed
@Differ3nce Differ3nce deleted the fix/prisma-migrations-direct-url branch February 25, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant