R
Railway5mo ago
SHxKM

Where should I run my Django migrations (Dockerfile)

So I’ve successfully deployed two services to Railway this weekend. I’m using compose for local development but since Railway doesn’t support that I deployed using the Dockerfile, overriding the ENTRYPOINT for one of the services. One thing I don’t particularly like about my setup is that Django DB migrations are being run in the ENTRYPOINT code, which ties this operation to the container’s boot. Ideally this should be some kind of pre/post hook. Do I have other options?
5 Replies
Percy
Percy5mo ago
Project ID: 87f6d50b-7bab-488e-b802-02f9edc442e3
SHxKM
SHxKM5mo ago
87f6d50b-7bab-488e-b802-02f9edc442e3
Brody
Brody5mo ago
running migrations during runtime at the start is perfectly fine, as long as you are using a readiness health check it doesnt matter how long the migrations take (within the set health check timeout) railway wont switch traffic over until the health check passes, aka when your app is actually ready to accept connections. https://docs.railway.app/reference/healthchecks
SHxKM
SHxKM5mo ago
Thanks @Brody. Does Railway offer anything like post/pre hooks? The migration command is supposed to be idempotent. But still, this feels like the wrong place to do it (and with Two apps using the same entry point, it runs it twice unnecessarily)
Brody
Brody5mo ago
railway does not, but migrations should be a no-op if no migrations are needed