Skip to content

Instantly share code, notes, and snippets.

@alex-zige
Created September 9, 2014 02:20
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 alex-zige/6f77d3a4e1403339c587 to your computer and use it in GitHub Desktop.
Save alex-zige/6f77d3a4e1403339c587 to your computer and use it in GitHub Desktop.
DB reset (drop & create & migrate & seed)
# check if stdout is a terminal...
if [ -t 1 ]; then
# see if it supports colors...
ncolors=$(tput colors)
if test -n "$ncolors" && test $ncolors -ge 8; then
bold="$(tput bold)"
underline="$(tput smul)"
standout="$(tput smso)"
normal="$(tput sgr0)"
black="$(tput setaf 0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
blue="$(tput setaf 4)"
magenta="$(tput setaf 5)"
cyan="$(tput setaf 6)"
white="$(tput setaf 7)"
fi
fi
echo "==> Dropping off existed database..."
rake db:drop
echo "${green}[OK]${normal}"
echo "==> Create new database..."
bundle exec rake db:create
echo "${green}[OK]${normal}"
echo "==> Reset database schema"
bundle exec rake db:migrate
echo "${green}[OK]${normal}"
echo "==> Seed database"
bundle exec rake db:seed
echo "${green}[OK]${normal}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment