How to ensure migrations to be run on a single web host #526
|
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 |
Replies: 4 comments 7 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 |
|
I am arriving a bit late to the discussion. But here it goes. |
|
@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. |
|
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. |
I confirm that passing
--version=$KAMAL_VERSIONworks whileVERSION=$KAMAL_VERSIONdidn't work. Below is what I have in.kamal/pre-deploy.