v1.8.0
What's Changed
Features
- Application environment config — Replaced
config/0callback withotp_app/0+ optionalinit/1, following the Ecto pattern. Config is read viaapplication:get_env(OtpApp, RepoModule), supporting multiple repos per application (#37)
Migration Guide
Replace your repo's config/0 callback:
%% Before
-callback config() -> map().
config() -> #{database => <<"my_db">>, ...}.
%% After
-callback otp_app() -> atom().
otp_app() -> my_app.Add config to your sys.config:
[{my_app, [
{my_repo, #{
database => <<"my_db">>,
hostname => <<"localhost">>,
username => <<"postgres">>,
password => <<"secret">>,
pool_size => 10
}}
]}].Optionally implement init/1 for runtime secrets:
init(Config) ->
Config#{password => list_to_binary(os:getenv("DB_PASSWORD", "postgres"))}.