Skip to content

v1.8.0

Choose a tag to compare

@Taure Taure released this 10 Mar 07:09
· 80 commits to main since this release
0bedba5

What's Changed

Features

  • Application environment config — Replaced config/0 callback with otp_app/0 + optional init/1, following the Ecto pattern. Config is read via application: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"))}.