4 ms·
> it's a bummer you lose all of your mix tasks That's not true at all. Mix Tasks are just code. Assuming you stashed them in /lib (or someplace that elixirc
by dnautics 6y ago
> it's a bummer you lose all of your mix tasks
That's not true at all. Mix Tasks are just code. Assuming you stashed them in /lib (or someplace that elixirc reaches) you can call them in a release using eval.
path/to/bin eval "Mix.Task.MyMixTask.run(...)"
- nickjj 6y agoAh nice to know. I've seen a bunch answers around having to jump through larger hoops to get to run mix tasks in releases. Are all config options still available to be read in mix tasks that are called that way? What about Mix functions like Mix.env()? If you Google around the topic of database migrations in Elixir releases you'll find like 5 different ways to do them with no clear "this is the best answer".
- Ndymium 6y agoMix doesn't exist in releases. You can get config options like normal, but not `Mix.env/0`. You can compile your current env into a config option though, and use that at runtime. Here's an example how to set up an Ecto migrator task with Mix releases: https://hexdocs.pm/phoenix/releases.html#ecto-migrations-and-custom-commands https://hexdocs.pm/phoenix/releases.html#ecto-migrations-and...