by
clemens
(23.09.2021)
Migrations Are Silently Skipped if They Do Not Have an Exs Extension
tl;dr
If you’ve got a migration that has ex
as its extension instead of exs
its silently skipped.
I’ve recently rerun a complete db migration, but for some reason a table was missing. A closer investigation
showed that the migration file wasn’t included in the schema_migrations
table, and that the file
for some reason had the extension .ex
instead of .exs
.
The migrations where run after a fresh install of the application, with the Ecto.Migrator.run/4
function
like this:
defmodule Migration do
def migrate do
{:ok, _} = Application.ensure_all_started(:otp_app)
path = Application.app_dir(:otp_app, "priv/repo/migrations")
Ecto.Migrator.run(Repo, path, :up, all: true)
end
end
Lesson learned: Make sure that your migration files always end with .exs
!