a year ago
I have postgres next to my app service in Railway. Automated Github environments are enabled in Railway.
I wanted to run Drizzle's database management tool, Drizzle Studio on each Railway deploy. To do that, I wanted to use a Github Action, so that when I push to my branch it'll run the studio.
However I run into the problem that I don't know how to dynamically insert the DATABASE_URL service variable that Railway generates. I could hardcode it for my main or staging environments, but was wondering if there's a way to dynamically insert these?
If not, any suggestions on how I could run a database admin tool that allows me to edit the postgres db spun up for each new Railway environment?
Thx
18 Replies
a year ago
1fb7b057-4030-4839-a1f8-68638ed52a4e
a year ago
perhaps the railway variables would help? -
a year ago
Hey Brody, thanks for the quick response. What about a different question -- do you have any tips for how to most easily admin a postgres database spun up in a new Railway environment? Just using pgadmin locally? Or deploying that as a template? Or is there another route that's obvious (but I'm missing)?
a year ago
i really like using dbgate locally so thats what id recommend - the dbgate template
a year ago
Oh cool. Had not heard of it. Will check it out.
a year ago
Followup question here. Would one typically admin a database by connecting to a production database from a local admin tool, or would you host a template of dbgate/pgadmin in every Railway environment next to the database? Is that a particularly resource intensive thing to run, or negligible?
a year ago
hard question to answer because i dont know your needs, for example you may not want to expose the database publicly so then you'd want deploy dbgate into your project, but if you dont care about having your database exposed publicly then using dbgate (or similar software) locally is an option, additionally, you should be able to have dbgate sleep so that it doesnt use any cpu and mem when you arent using it
a year ago
That's very helpful. If I enable sleeping such a service in Railway, can I still use private networking to have the admin tool connect to the database? Or would it have to use the PUBLIC_DATABASE_URL?
a year ago
yep since dbgate does the database connection from its backend so you will be able to use the private database url
a year ago
Ah that's nice. I just can't use private networking to connect to the admin service then?
a year ago
Not that that would be necessary.
a year ago
you could with tailscale but i think thats overkill
a year ago
Yeah no need.
a year ago
Will give these options a try. Thanks a bunch.
a year ago
no problem!
a year ago
dbgate is perfect for my needs. Will rock that for now.
a year ago
awsome!
a year ago
Should I close this post? I already tagged as 'solved'.