DATABASE_URL not found on first push to Github connected to Vercel review app deployment
Hi!
I have Vercel+github+neonDB set up to work together. I notice that anytime i create a new Pull Request on Github, Vercel correctly attempts to build the review app, but i get this error
prisma migrate deploy && prisma generate && next buildPrisma schema loaded from prisma/schema.prisma Error: Prisma schema validation - (get-config wasm) Error code: P1012 error: Environment variable not found: DATABASE_URL. --> prisma/schema.prisma:12 | 11 | provider = "postgresql" 12 | url = env("DATABASE_URL") | Validation Error Count: 1 However, the next commit i make (or if i redeploy it again) the error goes away. I suspect it has to do with a race condition that the DATABASE_URL env var is not set fast enough to the vercel review app environment before the review app attempts to deploy
3 Replies
wise-white•2w ago
Hey! When you created the Vercel managed integration, was the
Resource is required to be in an active state before deployment can start
toggle set to on, and did you enable the preview branch?
https://neon.com/docs/guides/vercel-managed-integration#connecting-the-database-to-a-vercel-projectNeon
Connecting with the Vercel-Managed Integration - Neon Docs
What the Vercel Managed Integration is How to install it from the Vercel Marketplace How (and why) to enable automated Preview Branching Where to manage billing and configuration Neon Managed Integrat...
equal-aquaOP•6d ago
where is the toggle>
?
tbh im not sure if i toggled it on or not when i set it up months ago 🙁
is ther ea way to check?
wise-white•6d ago
I've poked around in the Vercel dashboard, and unfortunately I don't see a way to change it after the fact right now. We're working on revamping the integration for a better DX, this will be one of the things I bring forward to address. If you create a new project, and have the toggle on, do you still face the same issue? If not, you could use our Import Data Assistant to make the migration very simple
Neon
Import Data Assistant - Neon Docs
When you're ready to move your data to Neon, our Import Data Assistant can help you automatically copy your existing database to Neon. You only need to provide a connection string to get started. You ...