Skip to content

Instantly share code, notes, and snippets.

@warrenseen
Created April 29, 2011 01:41
Show Gist options
  • Save warrenseen/947695 to your computer and use it in GitHub Desktop.
Save warrenseen/947695 to your computer and use it in GitHub Desktop.
Different DBs depending on git branch
<%
# Adds the current GIT repo to the database name.
parts = [ `git symbolic-ref HEAD 2>/dev/null`.chomp.sub('refs/heads/', ''), ENV['TEST_ENV'] ].compact
suffix = parts.length == 0 ? "" : "_#{parts.join("_")}"
%>
development:
adapter: postgresql
encoding: unicode
pool: 5
username: username
password: password
database: myapp_development<%= suffix %>
test: &test
adapter: postgresql
encoding: unicode
pool: 5
username: username
password: password
database: myapp_test<%= suffix %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment