Created
February 15, 2013 16:31
-
-
Save pmarreck/4961526 to your computer and use it in GitHub Desktop.
A little database.yml hack to get git-branch-specific databases.
As a prereq you need the git-branch.bash script that will define parse_git_branch which returns your current git branch (found elsewhere).
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
<% | |
db_name = nil | |
if ENV['SPECIFIC_DB'] | |
db_name = ENV['SPECIFIC_DB'].strip | |
else | |
cur_branch = `source ~/bin/git-branch.bash; parse_git_branch`.strip | |
db_name = cur_branch | |
end | |
db_name = db_name.gsub(/[\/\.]/,'_') | |
test_db = db_name + '_test' + ENV['TEST_ENV_NUMBER'].to_s | |
dev_db = db_name.strip | |
puts "Test database: #{test_db}" | |
puts "Development database: #{dev_db}" | |
%> | |
common: &common | |
adapter: mysql2 | |
encoding: utf8 | |
database: desk | |
username: root | |
password: | |
host: localhost | |
pool: 20 | |
socket: /tmp/mysql.sock | |
development: | |
<<: *common | |
database: <%= dev_db %> | |
reconnect: true | |
test: | |
<<: *common | |
database: <%= test_db %> | |
reconnect: true | |
production: | |
<<: *common | |
production_jobs: | |
<<: *common | |
production_reporting_v1: | |
<<: *common |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment