9 months ago
This question is mostly to help anyone searching for the same problem, and in the hope of a more elegant solution.
Django lets you run management commands like so:
python manage.py email_user --user Bob
Normally you would run this on the server. But Railway has no remote run/ssh. Therefore, with "railway run" the commands run locally - which means the private DATABASE_URL doesn't work.
So to get this to work, I need to expose my public URL via a reference variable DATABASE_PUBLIC_URL so that it's visible locally, and replace the private env var:
railway run bash
DATABASE_URL=$DATABASE_PUBLIC_URL
python manage.py email_user --user Bob
exit
Is there a nicer way of mapping the private database URL to public automatically when you do railway run bash
, or even better, of doing this in a one-liner? ie something like `railway run --public_db manage.py email_user`?
0 Replies
Status changed to Solved brody • 9 months ago