1.9 Release Ecto Migrations

382 views
Skip to first unread message

johanna.a...@gmail.com

unread,
May 4, 2019, 10:45:48 AM5/4/19
to elixir-lang-core
A common task to run in a build environment, but often separately from your actual application code, is database migrations. Distillery provides a suggested way of running them here: https://hexdocs.pm/distillery/guides/running_migrations.html and it's frequently linked to in the community. When you think about it, the Distillery guide is basically just convenience commands around evaluating an mfa and it also mentions using rpc as an alternative.

I'm wondering if there's been any thought into how migrations would be conveniently run with 1.9 releases. It would be helpful to new users if we could provide a "best practice" or at least suggested way of handling this. I've already seen this question pop up several times.

It probably shouldn't be in the official documentation, since not everyone uses ecto migrations and ecto is not a part of the core language, but I'm curious if someone has ideas on how this could be done in an elegant way. Maybe it could be added to the ecto documentation, now that releases are a core part of the language.

José Valim

unread,
May 4, 2019, 12:01:46 PM5/4/19
to elixir-l...@googlegroups.com
The short answer is that in Elixir releases you will be able to do:

    bin/my_app eval "MyApp.ReleaseTasks.migrate"

So the code in Distillery still works, you will have to adjust it a bit though and remove the arg processing bit, as you can call the functions directly . We will probably have a section about it in the Phoenix guides once Elixir v1.9 is out.

José Valim
Skype: jv.ptec
Founder and Director of R&D


--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/a463f2f1-332c-40e2-b570-8feccaf5b2ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages