Created
January 22, 2013 08:09
-
-
Save thbar/4592937 to your computer and use it in GitHub Desktop.
Little sh script to enable git config for branch-specific databases with Rails.
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
<% | |
# http://mislav.uniqpath.com/rails/branching-the-database-along-with-your-code/ | |
branch = `git symbolic-ref HEAD 2>/dev/null`.chomp.sub('refs/heads/', '') | |
suffix = `git config --bool branch.#{branch}.database`.chomp == 'true' ? "_#{branch}" : "" | |
%> | |
common: &common | |
adapter: mysql2 | |
encoding: utf8 | |
pool: 5 | |
username: root | |
# xxx | |
development: | |
<<: *common | |
database: app_dev<%= suffix %> | |
test: | |
<<: *common | |
database: app_test<%= suffix %> |
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
#!/usr/bin/env bash | |
# change branch first then run this to quickly enable branch-specific database | |
git config --bool branch.$(ruby -e 'puts `git symbolic-ref HEAD 2>/dev/null`.split("/").last.chomp').database true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment