I recently upgraded Phoenix v1.4 from v1.3 as well as Ecto v3.0 from v2.2.
And I found that the Ecto.Migrator.run/4
requires at least 2 DB pools, so I increased the pool size in the Distillery release tasks like this:
defmodule Nohogu.Tasks.ReleaseTasks do
@start_apps [:crypto, :ssl, :postgrex, :ecto]
@repo Nohogu.Repo
@otp_app :nohogu
def setup() do
IO.puts "Loading #{@otp_app}..."
Application.load(@otp_app)
IO.puts "Starting dependencies.."
Enum.each(@start_apps, &Application.ensure_all_started/1)
IO.puts "Creating database if not exists..."
@repo.__adapter__.storage_up(@repo.config)
{:ok, _} = @repo.start_link(pool_size: 2)
IO.puts "Running migrations..."
Ecto.Migrator.run(@repo, migrations_path(), :up, all: true)
# Signal shutdown
IO.puts "Success!"
:init.stop()
end
defp migrations_path(), do: Path.join([priv_dir(), "repo", "migrations"])
defp priv_dir(), do: "#{:code.priv_dir(@otp_app)}"
end
The two DB pools are used only to check and migrate if there’s a new migrations.
Though there’s no problem occurred yet, I wanted to know whether the pools are returned or occupied. If it’s not returned then please help me making them returned back.