The code below in config.exs will set the application_name in postgresql to "myapp". How can I use the Elixir node name instead? (using Kernel.node here causes an argument error)
config :db, DB.Repo,
adapter: Ecto.Adapters.Postgres,
database: "ahv2",
username: "troy",
password: "pass",
hostname: "localhost",
parameters: [
{:application_name, "myapp"}
]
You can use the init/2
callback added to Ecto in v2.1.0. The following code should work (but I have not tested it). You need to add this it to your Repo
module after use Ecto.Repo, ...
def init(_, config) do
{:ok, put_in(config, [:parameters, :application_name], Node.self |> to_string)}
end