Phoenix Deploying with Releases guides misprint?

in the Ecto migrations and custom commands

def rollback(repo, version) do
    {:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
  end

Shouldn’t you add Application.load(@app) inside the body of rollback/2?

https://hexdocs.pm/ecto_sql/Ecto.Migrator.html#with_repo/3

It starts the default required apps for you (you can configure more for it to start).

2 Likes

However there’s still one error :

05:29:46.665 [error] GenServer #PID<0.205.0> terminating
** (RuntimeError) connect raised KeyError exception: key :database not found. The exception details are hidden, as they may contain sensitive data such as database credentials. You may set :show_sensitive_data_on_connection_error to true when starting your connection if you wish to see all of the details
    (elixir) lib/keyword.ex:393: Keyword.fetch!/2
    (postgrex) lib/postgrex/protocol.ex:92: Postgrex.Protocol.connect/1
    (db_connection) lib/db_connection/connection.ex:69: DBConnection.Connection.connect/2
    (connection) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil

Connection.enter_connect/5 seems closely coupled with the phoenix app.

One way to solve this issue was to add Application.load(@app) inside the body of rollback/2.

Ah, you’re right, yeah. It needs access to the application environment. Nice catch!