Skip to content
An Elixir 1.9+ config provider to load a Rails style database.yml file
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Database YAML Config Provider

Build Status Coverage Status

An Elixir 1.9+ config provider to load a Rails style database.yml file with the following structure when booting up the application.

  adapter: postgresql
  database: testdb
  username: testuser
  password: myPa$sw0rd
  host: pgsqlhost
  port: 5432

The primary intention of this library is to simplify the migration process from a Rails app to Phoenix Framework.


  • Elixir >= 1.9


def deps do
    {:database_yaml_config_provider, "~> 0.1", only: :prod}


You need to register this DatabaseYamlConfigProvider as config provider in the releases section of your mix.exs file.

releases: [
  my_app: [
    config_providers: [
       repo: MyApp.Repo,
       path: "/production/shared/config/database.yml"}

By default, this config provider expects an ENV environment variable that contains the current hosting environment name to be present when booting the application.

Alternatively, you can set the environment directly when defining the config provider.

 repo: MyApp.Repo,
 path: "/production/shared/config",
 env: "production"}

Or you can speficy another env var containing the particular hosting environment on application startup:

 repo: MyApp.Repo,
 path: "/production/shared/config",
 env: {:system, "RAILS_ENV"}}

The same works for the location of the database file. You can specify an env var containing the path to a folder that contains the database.yml file:

 repo: MyApp.Repo,
 path: {:system, "RELEASE_CONFIG_PATH"}}

When the filename deviates from database.yml you can customize it, too:

 repo: MyApp.Repo,
 path: {:system, "RELEASE_CONFIG_PATH", "my_custom_database.yml"}}


Documentation can be found at HexDocs.

You can’t perform that action at this time.