DB Migration replaced DATABASE_URL with DATABASE_PRIVATE_URL
Hi π, I used the one-click DB migration and noticed that the
DATABASE_URL
env variable in Vercel disappeared and was replaced by a DATABASE_PRIVATE_URL
.
I can manually add the DATABASE_URL
back, but want to confirm that's ok to make sure I don't interfere with the Railway <> Vercel integration.23 Replies
Project ID:
5baffb91-9135-47a7-ad3a-10b894aa787f
5baffb91-9135-47a7-ad3a-10b894aa787f
@Brody explained the same thing yesterday to me (in regard of a nodejs backend). See https://discord.com/channels/713503345364697088/1067670924385583114/1194848344724484136 and https://discord.com/channels/713503345364697088/1067670924385583114/1198335583899107368
Or in short: You should continue by connecting via DATABASE_PRIVATE_URL as long as you connect to a db within the same railway-project to avoid high egress fees:
"that in fact might cost you more, since using databases outside of the current project limits you to connecting to it via the public network so you would be subjecting yourself to unnecessary egress fees, if you use a database that's in the same project you can connect to it via the private network and then you would eliminate the database to service egress fees!"
Thanks for your feedback π. Funny enough, I read your conversation with Brody yesterday when I searched for a solution before I posted π. I posted because I think my situation is different since my web app lives on Vercel, not within Railway.
However, maybe the right thing to do is move the web app to Railway as well βΒ it's been on my mind for a few weeks.
I haven't tried, but based on the docs I'm pretty sure the private database URL wouldn't work from the web app on Vercel to connect to the DB on Railway βΒ maybe I'm wrong though and they do have a private network π€?!
right a web app on vercel would need to use the public url
is it a next app?
It's SvelteKit 2.x
SSR or CSR?
SSR
oh it must be SSR if you're using a database lol
π
shouldn't be too hard at all to run on railway
I get the error during the build time already when I run Prisma to execute migrations against the DB, but it would fail at runtime too
Yeah I think I know what to do, just have to do it
π
SvelteKit's Node.js adapter, set the env variables, off we go
I get branch preview URLs too with Railway, right?
Ah yes, found it in the docs
if you perform migrations during build time you would need to use the public url for that and then switch to the private url during runtime because the build is not part of the private network yet
Ah that's super helpful, thanks for the heads up π
and keep in mind that those previous environments will have a database but it would be empty
Which previous environments?
railway has no native mechanics for cloning a database from one environment to another
Aha, preview I guess?
yeah the database created for every preview environment would be empty
That's alright, I have e2e tests and a seed script to populate test data.
Alright I think I'll just go ahead and give that a go
Look at that, https://railway.app/template/sRATcT (SvelteKit with Prisma template)
awesome, let me know if you run into issues
Will do
Migration complete, feel free to mark this as resolved.
That was very smooth. A SvelteKit app that uses Prisma to talk to a Postgres database. I've got a few serverless functions I need to turn into services on Railway, but that won't be a big deal.
The user experience and attention to detail is impressive throughout Railway π!
Awesome, glad to hear your experience was smooth!