Last active
September 12, 2018 20:45
-
-
Save monsha/4b9be25cbc0236c8f5c88de2dc2c2125 to your computer and use it in GitHub Desktop.
Database per branch - Rails
This file contains 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
parent=$1 | |
if [ -z $1 ]; then | |
echo "Parent db is empty" | |
echo "Using master" | |
parent="development_master" | |
fi | |
repo=`git rev-parse --abbrev-ref HEAD` | |
db=$(echo "development_$repo" | tr "-" "_") | |
echo 'Creating dev db' | |
createdb -U user -p 5433 -h localhost -T $parent $db | |
echo 'Done!' |
This file contains 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
<% | |
branch = `git rev-parse --abbrev-ref HEAD`.strip rescue nil | |
branch_spec = (branch.nil? ? "" : "_#{branch}").underscore.gsub(/[\.\/\-]/, '_') | |
%> | |
development: | |
<<: *default | |
database: app_development<%= branch_spec%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment