How to run database migrations?
In my Dockerfile, at the very end, I want to run the database migrations, then run the app server.
But it seems like my migrations are never executed.
In the Build Logs I see:
And in my Deploy Logs:
So that last CMD does seem to be running, why would the one right above it not run?
CMD ["/app/bin/migrate"]
18 Replies
In the template, you says say to run:
railway run mix ecto.migrate
but I want the migration to always run as part of the deploy. Any way to accomplish this?I don't think you can do 2 CMDs. How about
CMD can be like.
Sh migrateAndServer.sh
or however you run a sh ? Iirc
And just shove the commands in the sh fileOnly one CMD
thank you makes sense. I am getting this missing ENV database_url error.
I added ARG DATABASE_URL to the top of my Dockerfile.
RUN steps run at builtime afaik, dunno if railway populates env vars at that point
We do
Ah oke. All slymalino should need is the second green part then?
let me try that
Providing ENV works at builtime. If you get what I mean
Otherwise an sh file might do you aswell
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
^^Or that
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Awesome thanks so much guys loving railway
Interesting, should health checks be used when using any docker file with railway?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Ohhhhhh I was typing a follow up question about that. Makes sense. Time to do some research
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View