Skip to content

Instantly share code, notes, and snippets.

@tjmcewan
Last active December 24, 2015 13:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjmcewan/6805005 to your computer and use it in GitHub Desktop.
Save tjmcewan/6805005 to your computer and use it in GitHub Desktop.
app-agnostic, feature branch supporting, drop-in database.yml(based on http://www.reinteractive.net/posts/22-branch-specific-database-yml)
<%
app_name = Dir.getwd.split('/')[-1]
branch = `git symbolic-ref --short HEAD 2>/dev/null`.chomp.gsub(/\W/, '_')
db_name = branch.match(/feature/) ? "#{app_name}_#{branch}" : "#{app_name}_master"
puts "DATABASE: #{db_name}"
%>
mysql2: &mysql2
adapter: mysql2
socket: /tmp/mysql.sock
username: root
reconnect: false
pool: 5
postgresql: &postgresql
adapter: postgresql
host: localhost
min_messages: error
username: <%= `whoami`.strip %>
defaults: &defaults
encoding: utf8
password:
<<: *<%= ENV["RAILS_DB"] || "postgresql" %>
development: &development
database: <%= db_name %>
<<: *defaults
staging:
<<: *development
production:
<<: *development
test: &test
database: <%= db_name + "_test" %>
<<: *defaults
cucumber:
<<: *test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment