Run a command in production (rake)
Hi there, newcomer from Heroku here — I need to run a command in my production environment (in this instance
rake db:seed
but other times I need a console i.e. rails c
). On Heroku I would do heroku run rake db:seed
, how would I do this on Railway?6 Replies
Project ID:
8f20bec2-837e-46f0-8721-83eb63749406
8f20bec2-837e-46f0-8721-83eb63749406
Make sure you do
-
railway link
select the project
- railway service
select the actual service
- railway shell
to inject your env variables
- railway run rake db:seed
to seed your dbgoing the extra mile
ok rad, this was slightly more complicated because my app runs in a container locally (and doesn't work outside it), in case it's any use to others I created a new compose service:
with
bin/railway_entrypoint
:
and added .railway.env
with a RAILWAY_TOKEN
in . Then it's docker compose run --rm railway run rake db:seed
Thanks for confirming this is the recommended way!