- 
      
 - 
        
Save mazz/3e239e5159d02bab4f524455c0bc88dc to your computer and use it in GitHub Desktop.  
| defmodule Olivetree.ReleaseTasks do | |
| @start_apps [ | |
| :crypto, | |
| :ssl, | |
| :postgrex, | |
| :ecto | |
| ] | |
| def olivetree, do: Application.get_application(__MODULE__) | |
| def repos, do: Application.get_env(olivetree(), :ecto_repos, []) | |
| def seed do | |
| me = olivetree() | |
| IO.puts "Loading #{me}.." | |
| # Load the code for olivetree, but don't start it | |
| # :ok = Application.load(:olivetree) | |
| IO.puts "Starting dependencies.." | |
| # Start apps necessary for executing migrations | |
| Enum.each(@start_apps, &Application.ensure_all_started/1) | |
| # Start the Repo(s) for olivetree | |
| IO.puts "Starting repos.." | |
| Enum.each(repos(), &(&1.start_link(pool_size: 1))) | |
| # Run migrations | |
| migrate() | |
| # Run seed script | |
| Enum.each(repos(), &run_seeds_for/1) | |
| # Signal shutdown | |
| IO.puts "Success!" | |
| :init.stop() | |
| end | |
| def migrate, do: Enum.each(repos(), &run_migrations_for/1) | |
| def priv_dir(app), do: "#{:code.priv_dir(app)}" | |
| defp run_migrations_for(repo) do | |
| app = Keyword.get(repo.config, :otp_app) | |
| IO.puts "Running migrations for #{app}" | |
| Ecto.Migrator.run(repo, migrations_path(repo), :up, all: true) | |
| end | |
| # SEED-OFF | |
| def run_seeds_for(repo) do | |
| # Run the seed script if it exists | |
| seed_script = seeds_path(repo) | |
| if File.exists?(seed_script) do | |
| IO.puts "Running seed script.." | |
| Code.eval_file(seed_script) | |
| end | |
| end | |
| def migrations_path(repo), do: priv_path_for(repo, "migrations") | |
| # SEED-OFF | |
| def seeds_path(repo), do: priv_path_for(repo, "seeds.exs") | |
| def priv_path_for(repo, filename) do | |
| app = Keyword.get(repo.config, :otp_app) | |
| repo_underscore = repo |> Module.split |> List.last |> Macro.underscore | |
| Path.join([priv_dir(app), repo_underscore, filename]) | |
| end | |
| end | 
after adding :ecto_sql to @start_apps
olivetree-admin | {"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.Ecto.MigrationError',message=><<77,105,103,114,97,116,105,111,110,115,32,102,97,105,108,101,100,32,116,111,32,114,117,110,32,98,101,99,97,117,115,101,32,116,104,101,32,99,111,110,110,101,99,116,105,111,110,32,112,111,111,108,32,115,105,122,101,32,105,115,32,108,101,115,115,32,116,104,97,110,32,50,46,10,10,69,99,116,111,32,114,101,113,117,105,114,101,115,32,97,32,112,111,111,108,32,115,105,122,101,32,111,102,32,97,116,32,108,101,97,115,116,32,50,32,116,111,32,115,117,112,112,111,114,116,32,99,111,110,99,117,114,114,101,110,116,32,109,105,103,114,97,116,111,114,115,46,10,87,104,101,110,32,109,105,103,114,97,116,105,111,110,115,32,114,117,110,44,32,69,99,116,111,32,117,115,101,115,32,111,110,101,32,99,111,110,110,101,99,116,105,111,110,32,116,111,32,109,97,105,110,116,97,105,110,32,97,32,108,111,99,107,32,97,110,100,10,97,110,111,116,104,101,114,32,116,111,32,114,117,110,32,109,105,103,114,97,116,105,111,110,115,46,10,10,73,102,32,121,111,117,32,97,114,101,32,114,117,110,110,105,110,103,32,109,105,103,114,97,116,105,111,110,115,32,119,105,116,104,32,77,105,120,44,32,121,111,117,32,99,97,110,32,105,110,99,114,101,97,115,101,32,116,104,101,32,110,117,109,98,101,114,10,111,102,32,99,111,110,110,101,99,116,105,111,110,115,32,118,105,97,32,116,104,101,32,112,111,111,108,32,115,105,122,101,32,111,112,116,105,111,110,58,10,10,32,32,32,32,109,105,120,32,101,99,116,111,46,109,105,103,114,97,116,101,32,45,45,112,111,111,108,45,115,105,122,101,32,50,10,10,73,102,32,121,111,117,32,97,114,101,32,114,117,110,110,105,110,103,32,116,104,101,32,69,99,116,111,46,77,105,103,114,97,116,111,114,32,112,114,111,103,114,97,109,109,97,116,105,99,97,108,108,121,44,32,121,111,117,32,99,97,110,32,99,111,110,102,105,103,117,114,101,10,116,104,101,32,112,111,111,108,32,115,105,122,101,32,118,105,97,32,121,111,117,114,32,97,112,112,108,105,99,97,116,105,111,110,32,99,111,110,102,105,103,58,10,10,32,32,32,32,99,111,110,102,105,103,32,58,109,121,95,97,112,112,44,32,82,101,112,111,44,10,32,32,32,32,32,32,46,46,46,44,10,32,32,32,32,32,32,112,111,111,108,95,115,105,122,101,58,32,50,32,35,32,97,116,32,108,101,97,115,116,10>>},[{'Elixir.Ecto.Adapters.SQL',raise_pool_size_error,0,[{file,"lib/ecto/adapters/sql.ex"},{line,702}]},{'Elixir.Ecto.Adapters.SQL',lock_for_migrations,4,[{file,"lib/ecto/adapters/sql.ex"},{line,688}]},{'Elixir.Ecto.Migrator',lock_for_migrations,3,[{file,"lib/ecto/migrator.ex"},{line,302}]},{'Elixir.Enum','-each/2-lists^foreach/1-0-',2,[{file,"lib/enum.ex"},{line,765}]},{'Elixir.Enum',each,2,[{file,"lib/enum.ex"},{line,765}]},{'Elixir.Olivetree.ReleaseTasks',seed,0,[{file,"lib/olivetree/release_tasks.ex"},{line,31}]},{init,start_em,1,[]},{init,do_boot,3,[]}]}} olivetree-admin | init terminating in do_boot ({,[{Elixir.Ecto.Adapters.SQL,raise_pool_size_error,0,[{_},{_}]},{Elixir.Ecto.Adapters.SQL,lock_for_migrations,4,[{_},{_}]},{Elixir.Ecto.Migrator,lock_for_migrations,3,[{_}
error: