[Doc] Running mix tasks using Elixir releases
slashdotdash opened this issue · 1 comments
slashdotdash commented
The EventStore mix tasks, such as mix event_store.create
, delegate the actual work to corresponding task modules defined inside EventStore (in lib/mix/tasks
) so you can use them directly:
Mix releases support running one-off commands and using a helper module to define these commands, example below.
defmodule MyApp.ReleaseTasks do
def init_event_store do
{:ok, _} = Application.ensure_all_started(:postgrex)
{:ok, _} = Application.ensure_all_started(:ssl)
:ok = Application.load(:eventstore)
config = EventStore.Config.parsed()
EventStore.Tasks.Create.exec(config, [])
EventStore.Tasks.Init.exec(config, [])
end
end
Run a release task:
bin/RELEASE_NAME eval "MyApp.ReleaseTasks.init_event_store()"
norpan commented
Just wanted to note here that you now (version 1.0) have to do Your.EventStore.config()
instead of EventStore.Config.parsed()
.