Last active
December 14, 2015 19:49
-
-
Save zeroeth/5139770 to your computer and use it in GitHub Desktop.
per branch database.yml for rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # add 'grit' and 'colored' to Gemfile | |
| # you can delete the color methods on line #9 if you don't want to install colored gem. | |
| # uses your typical app_development, app_test if git is under master. | |
| # adds _branch_name to end if not. | |
| <% | |
| git_repo = Grit::Repo.new(".") | |
| postfix = git_repo.head.name == 'master' ? nil : git_repo.head.name | |
| app_name = Rails.application.class.parent_name.downcase | |
| database = [app_name, Rails.env, postfix].compact.join("_") | |
| puts "database branch: ".cyan.bold + "#{database}".magenta.bold | |
| %> | |
| defaults: &DEFAULTS | |
| adapter: postgresql | |
| encoding: unicode | |
| pool: 5 | |
| username: userhere | |
| password: xyzxyz | |
| development: | |
| <<: *DEFAULTS | |
| database: <%= database %> | |
| test: &TEST | |
| <<: *DEFAULTS | |
| database: <%= database %> | |
| staging: &TEST | |
| <<: *DEFAULTS | |
| database: <%= database %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment