The docs and example code suggest running your Rails database migrations (
rails db:migrate) as part of your build script.
I’ve been running the same build script for both my ruby web service and my (background) worker.
The idea here is that whichever service gets deployed first will take care of the migrations and the next one will see the database is already up-to-date and skip the migrations.
This has worked fine, but I now have a Rails app with slower database migrations. This leads to scenario where one service has already started migrating, but isn’t finished yet. The second service sees the database is out-of-date and also tries to migrate the database, which causes the
What’s the recommended approach here?
Running the migrations in the build script for only one service doesn’t cut it, because the other one might get deployed first.