Skip to content

Instantly share code, notes, and snippets.

@henrik
Created July 13, 2009 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save henrik/146080 to your computer and use it in GitHub Desktop.
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.
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