N
Neon2y ago
rival-black

DATABASE_URL conflict between Vercel and Neon?

Hi everyone. I am setting up Neon with github actions for a project using the tutorial provided here: https://neon.tech/blog/branching-with-preview-environments#:~:text=When%20you%20open%20the%20deploy%2Dproduction.yml%20file%2C%20you%20will%20see%20the%20following%3A It looks like it's working fine : when I generate + migrate the prisma schema, I can see the tables being created in Neon. However, when using the app, it seems that the DATABASE_URL that it points to is still the one indicated in the vercel environment variables. Therefore, my tables remain desperately empty. Note: I am not (yet?) using the Neon integration in vercel. Am I doing anything wrong? Thanks in advance
Neon
A database for every preview environment using Neon, GitHub Actions...
Learn how to create a Neon branch for every preview environment using Neon, GitHub Actions, and Vercel.
3 Replies
harsh-harlequin
harsh-harlequin2y ago
DATABASE_URL that it points to is still the one indicated in the vercel environment variables. You mentioned you're not using the integration, so how did this variable get set inside Vercel?
rival-black
rival-blackOP2y ago
Thanks for your quick answer. Until now, we were using the databases provided by Vercel, so DATABASE_URL was set manually via the Vercel console and has this shape : postgres://xxx@yyy-pooler.eu-central-1.postgres.vercel-storage.com/verceldb?pgbouncer=true&connect_timeout=15 Now, I'm setting this variable in the CI/CD with :
touch .env
echo DATABASE_URL=${{ steps.create_branch.outputs.db_url_with_pooler}}/neondb >> .env
echo DIRECT_DATABASE_URL=${{ steps.create_branch.outputs.db_url}}/neondb >> .env
npx prisma generate
npx prisma migrate deploy
touch .env
echo DATABASE_URL=${{ steps.create_branch.outputs.db_url_with_pooler}}/neondb >> .env
echo DIRECT_DATABASE_URL=${{ steps.create_branch.outputs.db_url}}/neondb >> .env
npx prisma generate
npx prisma migrate deploy
Hi everyone, I fixed my problem by using the --env option of the vercel deploy command :
vercel deploy --prebuilt --env POSTGRES_PRISMA_URL=${{ steps.create-branch.outputs.db_url }}?sslmode=require [...]
vercel deploy --prebuilt --env POSTGRES_PRISMA_URL=${{ steps.create-branch.outputs.db_url }}?sslmode=require [...]
unwilling-turquoise
unwilling-turquoise2y ago
Quick side note here: I believe the ENVs provided by Vercel Postgres are POSTGRES_* so should not conflict with the DATABASE_* naming used by the Neon integration.

Did you find this page helpful?