Skip to content

Instantly share code, notes, and snippets.

@oshanz
Forked from henrik/database.yml
Created March 2, 2020 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oshanz/47387eacf5171121bab96fce78ad680f to your computer and use it in GitHub Desktop.
Save oshanz/47387eacf5171121bab96fce78ad680f to your computer and use it in GitHub Desktop.
Per-branch development database with Git and Ruby on Rails.
<%
DEFAULT_DB = 'myapp_development'
DB_BRANCHES = %w[ t79 ]
branch = `git symbolic-ref HEAD 2> /dev/null`.chomp.split('/').last
dev_db = DB_BRANCHES.include?(branch) ? branch.gsub(/[^a-zA-Z0-9_]/, '') : DEFAULT_DB
puts "Using dev database: #{dev_db.inspect}"
%>
development:
database: <%= dev_db %>