I’m following the approach from this post to make my release_tasks module which is as follows:
defmodule :release_tasks do
def migrate do
{:ok, _} = Application.load(:myapp)
Enum.map(Application.spec(:myapp, :applications), &Application.load(&1))
Enum.map(Application.spec(:myapp, :applications), &Application.ensure_all_started(&1))
path = Application.app_dir(:myapp, "priv/repo/migrations")
Ecto.Migrator.run(MyApp.Repo, path, :up, all: true)
:init.stop()
end
end
When I try to run the task I get configuration for MyApp.Repo not specified in :myapp environment
error which I’m having trouble to explain:
{"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.ArgumentError',message=><<"configuration for MyApp.Repo not specified in :myapp environment">>},[{'Elixir.Ecto.Repo.Supervisor',config,3,[{file,"lib/ecto/repo/supervisor.ex"},{line,23}]},{'Elixir.Ecto.Migration.SchemaMigration',get_source,1,[]},{'Elixir.Ecto.Migration.SchemaMigration',create_migrations_table,3,[{file,"lib/ecto/migration/schema_migration.ex"},{line,38}]},{'Elixir.Ecto.Migrator',migrated_versions,2,[{file,"lib/ecto/migrator.ex"},{line,43}]},{'Elixir.Ecto.Migrator',run,4,[{file,"lib/ecto/migrator.ex"},{line,142}]},{release_tasks,migrate,0,[{file,"lib/release_tasks.ex"},{line,9}]},{init,start_it,1,[]},{init,start_em,1,[]}]}}
In release sys.config
Elixir.MyApp.Repo
is present under myapp
.
What’s happening?
Any ideas appreciated!