Skip to content

Instantly share code, notes, and snippets.

@sao
Created September 9, 2014 16:10
Show Gist options
  • Save sao/5683feb4af2e2c1d4841 to your computer and use it in GitHub Desktop.
Save sao/5683feb4af2e2c1d4841 to your computer and use it in GitHub Desktop.
Dynamic database names on git checkout.
#
# requires 'gem install git'
#
<%
current_branch = Git.open('.').current_branch
unless current_branch =~ /(master|rebasing)/
branch = "_#{current_branch}"
end
%>
development:
adapter: postgresql
encoding: unicode
database: workstiming_development<%= branch %>
host: localhost
pool: 5
username: aisdata
password: wRew2pheheGE
test:
adapter: postgresql
encoding: unicode
database: aisdata_test<%= branch %>
host: localhost
pool: 5
username: aisdata
password: wRew2pheheGE
@sao
Copy link
Author

sao commented Sep 9, 2014

Used in conjunction with my db helper so I can easily create a new database for each branch I work on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment