How to ensure migrations to be run on a single web host #526
Replies: 4 comments 4 replies
-
Would like to bump this up. Been looking around for suggestions and there's not a lot of info regarding handling migrations. Having a consolidated answer we can reference would be great! We initially handled migrations in our entrypoint - however we later experienced some issues with longer running data migrations that involved fetching and syncing data with external an external service. Ideally we could run this in the For now we have to either run the long migrations manually after a deploy or do a |
Beta Was this translation helpful? Give feedback.
-
I am arriving a bit late to the discussion. But here it goes. |
Beta Was this translation helpful? Give feedback.
-
@fesilvajacquier yes agree & I think tags are for this purpose only, to set env vars for a specific host. how to set tags? Example
and in docker-entrypoint we can use this MIGRATION env variable to run the migrations. |
Beta Was this translation helpful? Give feedback.
-
You should be able to do something like this in a pre-deploy hook I think:
If using destinations you'd need to make sure to pass the current one as well (you can get the current one in the KAMAL_DESTINATION env variable in hooks). The The ENV tag approach looks nice as well, but using a pre-deploy hook ensures the migrations are run before any of the new app containers are booted. |
Beta Was this translation helpful? Give feedback.
-
We have several hosts for web. Is there currently a way to ensure that Rails migrations will run only on a single web host?
Currently we start our containers with
docker-entrypoint
file that is listed below.Beta Was this translation helpful? Give feedback.
All reactions