I usually have created a mix task for data migrations to avoid putting the app down, but today I learned that ecto migrations accept an arg
--migrations-path to their commands which allow us to have 2 separate folders for migrations.
With that we can easily use the default
priv/repo/migrations folder for automatic migrations (for running on deployments) and a separate folder, let’s say
priv/repo/data_migrations that we can run when it’s more convenient.
So in prod we run migrations on deploy and data_migrations on a quite time for the app to avoid downtime. And in dev and test env we just run them all as we usually have smaller dataset, so not a big deal.
Here’s a good post about this strategy.Tweet