Created
March 15, 2012 17:37
-
-
Save chuckbergeron/2045523 to your computer and use it in GitHub Desktop.
One Database Per Branch, Per Environment
This file contains 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
CURRENT_BRANCH = `git status | head -1`.to_s.gsub('# On branch ','').chomp |
This file contains 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
<% | |
database_prefix = 'app' | |
environments = %W( development test ) | |
%> | |
defaults: &defaults | |
pool: 5 | |
adapter: mysql2 | |
encoding: utf8 | |
reconnect: false | |
username: root | |
password: | |
host: localhost | |
<% environments.each do |environment| %> | |
<%= environment %>: | |
<<: *defaults | |
database: <%= [ database_prefix, CURRENT_BRANCH, environment ].join('_').underscore %> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just added a .underscore call at the end of the interpolated database string. Wasn't happy when a git branch had a "-" in it.