Skip to content

Instantly share code, notes, and snippets.

@sebastiangeiger
Created July 25, 2013 19:31
Show Gist options
  • Select an option

  • Save sebastiangeiger/6082986 to your computer and use it in GitHub Desktop.

Select an option

Save sebastiangeiger/6082986 to your computer and use it in GitHub Desktop.
Toy script that runs each rails migration individually to determine which one fails. COLORS, YAY!
#!/bin/bash
reset='\e[0m';
green='\e[1;32m';
red='\e[1;31m';
rake db:drop db:create
ls -1 db/migrate | sort | cut -f 1 -d '_' | while read version; do
printf "${version}"
ERROR=$(((rake db:migrate:up VERSION=${version}; ) 1>/dev/null) 2>&1)
if [ $? -eq 0 ]; then
printf "\r${green}${version}${reset}\n"
else
printf "\r${red}${version}${reset}\n"
echo "ERROR:"
echo ${ERROR}
break
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment