Setting the default database on Vercel
Hi there π
We've integrated our project that is deployed on Vercel with Neon and I'm trying to achieve the following:
- Have a database for the "Production" environment in Vercel (eg.
my-app-production)
- Have a separate database (that contains different data) for every other preview on Vercel.
The Production environment on Vercel is deployed via a production environment and we have a next branch that is our main branch (all our PRs get merged into it) which we base off all our preview branches of.
What I've tried so far is the following:
- Created the two databases
- Migrated data to each database, I've got the my-app-production and my-app-development databases fully set up.
- Went to Integrations > Added > Vercel > Manage > Settings and tried to set the my-app-development database as the default under "Default database and Role".
- Saw that all environmnent variables that were set by Neon had switched to the my-app-development database.
- Created a new git branch locally eg. fotis/test-12345
- Pushed the branch on GitHub which triggers a new Vercel deployment and the environment variable generation.
- Saw that the environment variables for new deployments still get created with the original database (my-app-production).
Is there perhaps a bug in the Vercel integration? Is there any way I can achieve the above?
Thank you π12 Replies
flat-fuchsiaβ’17mo ago
Hey Fotis - sorry we missed this yesterday. I've asked internally to see if any Vercel experts know how to achieve the setup you're describing here
xenial-blackOPβ’17mo ago
Thank you @andyhats π
flat-fuchsiaβ’17mo ago
Hey just heard back from the team. The setup you are describing makes total sense, and we have an internal issue that almost exactly matches the scenario you are describing. The blocker right now is that you cannot branch from something other than the primary branch. We've linked this thread so that we can update you when there are customer-facing developments on this feature. Don't have a timeline right now.
xenial-blackOPβ’17mo ago
That's awesome. I'm totally happy to always be branching out of the main branch as long as I'm able to use a different database. For example the following would work for me:
main branch -> db-prod & db-dev
then every vercel preview branch created could use db-dev as the defaultflat-fuchsiaβ’17mo ago
ohhhhh I missed that bit. Most of the time people use 'database' to mean 'project' but here you're actually talking about proper Postgres databases
xenial-blackOPβ’17mo ago
Just to clarify, I'm talking about this part. I have two databases:
xxxx and xxxx-dev, I'm trying to set the xxxxx-dev (postgres) database as the default but doesn't work. New Environment Variables registered in Vercel, use the xxxx (postgres) database instead.
xenial-blackOPβ’17mo ago
@andyhats sorry for dragging you into this one again but I'm not sure if you've seen this small clarification message βοΈ
future-harlequinβ’16mo ago
@andyhats Hi, any chance there's an update on this? If we could make Vercel preview branches use another database as default (e.g.
db-dev), that would make our flow workable. Currently, it's quite broken unfortunately! We have to manually update the database name for every PR deployment and then redeploy - tremendous pain π¬flat-fuchsiaβ’16mo ago
hi you two - I think the best fix is going to involve switching away from your current "multiple databases in one instance" approach to instead using a new feature in development "Create preview branch from non-primary branch"
Here's a copy/paste of the description:
So in that workflow, you'll create a branch called
db-dev and change its password, and then create preview branches from db-dev instead of mainxenial-blackOPβ’16mo ago
@andyhats I signed up for the "early access" program, currently waiting for it. I'd say there's a small ui glitch there in the Vercel settings though. Drop downs don't expand either

flat-fuchsiaβ’16mo ago
thanks for the heads up - I'll pass it along
fair-roseβ’14mo ago
Where did you find this config? I want to do this since master has sensitive data, and can't find it on either vercel or neons side. Currently the workaround I'm using so that preview builds, using a branch off develop, is setting develop as our default branch in neon.