R
Railwayβ€’5mo ago
Mike

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
Percy
Percyβ€’5mo ago
Project ID: 5baffb91-9135-47a7-ad3a-10b894aa787f
Mike
Mikeβ€’5mo ago
5baffb91-9135-47a7-ad3a-10b894aa787f
saintcore
saintcoreβ€’5mo ago
@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!"
Mike
Mikeβ€’5mo ago
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 πŸ€”?!
Brody
Brodyβ€’5mo ago
right a web app on vercel would need to use the public url is it a next app?
Mike
Mikeβ€’5mo ago
It's SvelteKit 2.x
Brody
Brodyβ€’5mo ago
SSR or CSR?
Mike
Mikeβ€’5mo ago
SSR
Brody
Brodyβ€’5mo ago
oh it must be SSR if you're using a database lol
Mike
Mikeβ€’5mo ago
πŸ™‚
Brody
Brodyβ€’5mo ago
shouldn't be too hard at all to run on railway
Mike
Mikeβ€’5mo ago
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
Brody
Brodyβ€’5mo ago
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
Mike
Mikeβ€’5mo ago
Ah that's super helpful, thanks for the heads up πŸ™
Brody
Brodyβ€’5mo ago
and keep in mind that those previous environments will have a database but it would be empty
Mike
Mikeβ€’5mo ago
Which previous environments?
Brody
Brodyβ€’5mo ago
railway has no native mechanics for cloning a database from one environment to another
Mike
Mikeβ€’5mo ago
Aha, preview I guess?
Brody
Brodyβ€’5mo ago
yeah the database created for every preview environment would be empty
Mike
Mikeβ€’5mo ago
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)
Brody
Brodyβ€’5mo ago
awesome, let me know if you run into issues
Mike
Mikeβ€’5mo ago
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 😍!
Brody
Brodyβ€’5mo ago
Awesome, glad to hear your experience was smooth!