I’m in the process of moving an Erlang umbrella app to Mix (in order to gradually port it to Elixir) and only the final piece of the puzzle is now missing: A way to run migrations (using sqitch) that has access to the release’s config.
When building an Erlang release, the generated script in
_build/prod/rel/myproject/bin/myproject includes an
escript target that runs the given escript file in the same environment as the release:
_build/prod/rel/myproject/bin/myproject escript /path/to/my_script_file.escript
I use this to run migration scripts that read the various apps’ configs and use the config values when calling out to sqitch to ensure that DB schemas are up to date.
Elixir releases contain a similar command –
eval – that can be used to [execute] the given expression on a new, non-booted system. This almost sounds like what I want, but I’d prefer to not create an actual application that will be part of the release in order to run e.g.
_build/prod/rel/myproject/bin/myproject eval MyProject.Migration.migrate().
Is it possible to include a script that I can run and have access to the release’s environment? (Or is there another way to achieve this?)