Created
July 13, 2009 12:21
-
-
Save henrik/146080 to your computer and use it in GitHub Desktop.
Simple per-branch databases in Rails dev. Also different adapters for JRuby vs. MRI.
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
shared: &shared | |
# Use different adapters with JRuby vs. MRI | |
adapter: <%= defined?(JRuby) ? "jdbcmysql" : "mysql" %> | |
encoding: utf8 | |
username: root | |
password: | |
host: localhost | |
socket: /opt/local/var/run/mysql5/mysqld.sock | |
<% | |
# For the git branches listed in DB_BRANCHES, use a dev DB with the same name. | |
# For other branches, use the DEFAULT_DB. | |
DEFAULT_DB = 'myproject_dev' | |
DB_BRANCHES = %w[ t123 t456 ] | |
branch = `git symbolic-ref HEAD 2> /dev/null`.chomp.split('/').last | |
dev_db = DB_BRANCHES.include?(branch) ? branch : DEFAULT_DB | |
puts "Using dev database: #{dev_db.inspect}" | |
%> | |
development: | |
<<: *shared | |
database: <%= dev_db %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment