-
-
Save Narnach/47385 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
# Usage: s2b.sh branchname | |
# Easily switch between branches and their databases for Rails projects. | |
# Checks out given branch and copies the branch's database.yml to the active database.yml | |
# Outputs a small list of databases being used. | |
# Make sure you have set up your branch's database.yml in #{RAILS_ROOT}/config/database.#{branchname}.yml | |
git checkout $1 && cp config/database.$1.yml config/database.yml | |
databases=`grep --colour=auto database config/database.yml | grep -v ^# | sed s/database\:// | tr -d '\012' | sed -E s/^\ +\|\ +$// | sed -E s/\ +/,\ /g` | |
echo "Using databases: $databases" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment