New "mix release" and DB migrations

I’ve been playing with the new Elixir 1.9.0-dev branch to try out the new “releases”. Everything is working but the piece left unsolved is running DB migrations and seeds.

Previously with Distillery I did those as release tasks. I haven’t found any examples or recommended approaches to this yet.

Looking for guidance or core-team information on what the expected or recommended approach should be.

1 Like

I asked that question on the mailing list and the short answer is, basically the same way you do with Distillery. Release tasks in Distillery are just custom commands, and what the guide for migrations does is a custom command that evals a function. You can do that in 1.9 releases as well. So it’s the exact same thing, except instead of

app/bin/hello migrate

you run

app/bin/hello eval "Hello.ReleaseTasks.migrate"!topic/elixir-lang-core/OkJ9C4U-C-k


Thanks @jola! That initial eval piece was the missing bit for me. Awesome!

We are also adding new functions to Ecto.SQL to abstract the bureaucracy of starting new applications and repositories to run migrations in releases:

This code was already inside of Ecto.SQL, we are just making it public.