-
-
Save oshanz/47387eacf5171121bab96fce78ad680f to your computer and use it in GitHub Desktop.
Per-branch development database with Git and Ruby on Rails.
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
<% | |
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 %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://reinteractive.com/posts/22-branch-specific-database-yml
http://www.mobalean.com/blog/2013/03/03/keep-database-in-sync-with-current-branch
https://thebrainfiles.wearebrain.com/db-per-feature-in-rails-2c1b491bc3d4
https://stackoverflow.com/questions/4735058/how-to-work-with-git-branches-and-rails-migrations
https://blog.codeship.com/git-database-branches/
https://manas.tech/blog/2016/01/08/switching-rails-app-database-per-git-branch/