Skip to content

Instantly share code, notes, and snippets.

@akm
Created September 17, 2009 02:08
Show Gist options
  • Save akm/188307 to your computer and use it in GitHub Desktop.
Save akm/188307 to your computer and use it in GitHub Desktop.
database.yml.example
<%
db_proj_name = 'your project name on db'
scm_proj_name = 'your project name on scm'
branch = `git status`.scan(/\# On branch ([^\s]+?)$/).flatten.first if File.exist?('./.git')
branch ||= `svn info`.scan(/\/#{scm_proj_name}\/(?:branches\/(.*?))\/|(trunk)/).flatten.compact.first if File.exist?('./.svn')
branch = branch ? '_' << branch.sub(/^local[\-_]/, '').sub('-', '_') : ''
%>
common: &common
adapter: mysql
encoding: utf8
username: root
password:
socket: /opt/local/var/run/mysql5/mysqld.sock
development:
database: <%= db_proj_name %><%= branch %>_development
<<: *common
test:
database: <%= db_proj_name %><%= branch %>_test
<<: *common
production:
database: <%= db_proj_name %><%= branch %>_production
<<: *common
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment