I tried searching this channel but haven't found a...
# orm-help
r
I tried searching this channel but haven't found any good solutions to dealing with vercel's preview branches & having multiple databases. Do y'all set up staging database branches and force push to staging branches in order to test out changes in a QA environment? Otherwise, multiple devs with different branches pushing to the preview
DATABASE_URL
will all have migration errors. Anyone have a solid creative solution to this besides force pushing to staging branches w/ specific `DATABASE_URL`s defined to them?
👀 2
c
I eventually decided to just stop having migrations in more than one branch at a time, it's problematic for sure. I wonder if PlanetScale's branching capability is the ultimate solution here?
n
I personally haven’t dealt with vercels preview feature. My thought would be to have a shadow DB which is a copy of the DB and have env variables for preview into a seperate env file
preview.env
👀 1
r
Giving me ideas here… I wonder if there is a way to clean up a db name in a staging db. Could run a script that cleans up dbs created 30+ days ago and have preview branches deploy from scratch to a randomly generated db name
c
Are you using Postgres?
n
I am using Postgres for mine. we have a specific env folder with env variable for each stage (eg. local > test > experiment > development > production) that depending on what stage I want to point my root env file ill do a copy to it from the env folder in a npm script named
set-env:dev
and so forth. One gotcha you’ll get is windows users use
copy
whereas linux(MacOS) will use
cp
.