Reputation: 772
I have Django project deployed to Railway.app. I've installed Railway CLI, but can't understand how to run python manage.py makemigrations
and so on in its CLI to make Django runnig.
My laptop is running Windows 10 Home.
Ho do I?
UPDATE. Some results from the answers:
In settings.py use Railway's DB. In this case you don't need to run CLI commands via Railway CLI, you may use local and it will affect the Railway's DB.
railway login
railway link your_railway's_project_Id
railway status
to check whether you are in the right projectrailway run python manage.py createsuperuser
railway run python manage.py collectstatic
make migrations
migrate
still don't run on remote server.
In Procfile
I used code:
web: python manage.py migrate && gunicorn project_name.wsgi
Upvotes: 7
Views: 11829
Reputation: 1
You can add python manage.py makemigrations
as a command during your pre-deploy step.
Steps to complete as of Feb 2025:
Settings
Deploy
section.Add pre-deploy step
button underneath the Custom Start Command
section.Other comments suggest you should use railway run
to run the command. This is not true.
The railway run
command as described on the docs here and here state that the command injects secrets from your service environment on Railway into your local environment. This does not allow you to run commands directly in the Railway environment as if accessing the server via SSH, but rather allows you to run your service locally with all the environment variables required.
Upvotes: 0
Reputation: 5638
So, you should run IN YOUR PROJECT REPOSITORY :
railway link
-> Then select your projectrailway run <your command>
Upvotes: 3
Reputation: 39
you can do that by using railway run (command to be executed)
for example to create a superuser, use
railway run python manage.py createsuperuser
Check out this article
PS: Ensure you are in the same directory as that of the production because it will run both on local and production environment.
Upvotes: 3