Skip to content

Instantly share code, notes, and snippets.

@lengarvey
Created May 30, 2013 03:04
Show Gist options
  • Save lengarvey/5675496 to your computer and use it in GitHub Desktop.
Save lengarvey/5675496 to your computer and use it in GitHub Desktop.
Example database.yml that has different database per git branch
development:
adapter: postgresql
<% if `git symbolic-ref HEAD 2>/dev/null`.chomp.sub('refs/heads/', '').gsub(/\W/, '_') =~ /hotfix|release/ %>
database: YOUR_APP_NAME_HERE_development_master <% else %>
database: YOUR_APP_NAME_HERE_development_<%= `git symbolic-ref HEAD 2>/dev/null`.chomp.sub('refs/heads/', '').gsub(/\W/, '_')[0..20] %> <% end %>
pool: 5
timeout: 5000
host: localhost
test:
adapter: postgresql
<% if `git symbolic-ref HEAD 2>/dev/null`.chomp.sub('refs/heads/', '').gsub(/\W/, '_') =~ /hotfix|release/ %>
database: YOUR_APP_NAME_HERE_test_master
<% else %>
database: YOUR_APP_NAME_HERE_test_<%= `git symbolic-ref HEAD 2>/dev/null`.chomp.sub('refs/heads/', '').gsub(/\W/, '_')[0..20] %>
<% end %>
pool: 5
timeout: 5000
host: localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment