Hi all,
I’m trying to get a Phoenix app into a deployable state in a docker container. I can get it up and running no problem if I point it to an existing and migrated postgres DB.
When I tried to running migrations I ran into the following problem. When running via ‘eval’ I get the following errors.
./prod/rel/my_app/bin/my_app eval "MyApp.Release.ReleaseTasks.migrate(1)"
where is ‘ReleaseTask’ is a utility module to run the migrations, I get the following.
19:14:43.890 [error] GenServer #PID<0.227.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 1.10.4) lib/keyword.ex:399: Keyword.fetch!/2
(postgrex 0.15.3) lib/postgrex/protocol.ex:92: Postgrex.Protocol.connect/1
(db_connection 2.2.1) lib/db_connection/connection.ex:69: DBConnection.Connection.connect/2
(connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
(stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
In the repo section of ‘releases.exs’ I set :show_sensitive_data_on_connection_error to true but that configuration is never picked up.
Now, here’s the confusing part. If I run in ‘rpc’ move rather than ‘eval’ mode. It works fine. That is:
./prod/rel/my_app/bin/my_app rpc "MyApp.Release.ReleaseTasks.migrate(1)"
It works totally fine. Even though I got the DB migrated, I’d still like to understand what’s going on. I’d like to know:
- why ‘eval’ mode did not work at all.
- why show_sensitive_data_on_connection_error: true had no effect? As in I’m not running the config I think I’m running.
- why ‘rpc’ mode did work.
Thanks,
Adam