Git Product home page Git Product logo

heroku_db_env's Introduction

Features

  • Overwrite Heroku's auto generated database configuration

Installation

Add the gem to your gemfile

gem 'heroku_db_env'

Add your custom database configuation or overrides to the heroku_database.yml file. The format is identical to database.yml. The gem will also look for any environment variables in the format [env]_DATABASE_URL and merge the resulting connection hash into the database configuation.

Example

Lets assume that you are running in your production environment and your DATABASE_URL is set to

postgres://user:pass@hostname/db_prod

Heroku's auto-generated database.yml is actually an ERB script which will transform the DATABASE_URL environment variable to the following connection config when the file is read

production:
  adapter: postgres
  database: db_prod
  username: user
  password: pass
  host: hostname

Now lets say, for whatever reason, you are unhappy with the auto generated database configuration. You can overwrite it by providing a heroku_database.yml file in your config directory and/or by specifying environment specific DATABASE_URL env vars.

In your heroku_database.yml

production:
  pool: 10

reporting:
  pool: 5
  schema_search_path: reporting_schema

And your REPORTING_DATABASE_URL is set to

postgres://user:[email protected]/db_reporting

The final database configuration should look like

production:
  adapter: postgres
  database: db_prod
  username: user
  password: pass
  host: hostname
  pool: 10
reporting:
  adapter: postgres
  database: db_reporting
  username: user
  password: pass
  host: reporting.hostname
  pool: 5
  schema_search_path: reporting_schema

Run a db rake task against any configured database to test the setup

heroku run rake db:migrate RAILS_ENV=reporting

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.