Skip to content

Instantly share code, notes, and snippets.

@sergeych
Created September 11, 2011 22:14
Show Gist options
  • Save sergeych/1210201 to your computer and use it in GitHub Desktop.
Save sergeych/1210201 to your computer and use it in GitHub Desktop.
bash script: git pull && pass rails migrations if need
#!/bin/bash
#
# git pull && run migratoins if need
dbtime=`stat -f "%m" db/migrate`
schema=`stat -f "%m" db/schema.rb`
git pull || exit
# If either schema or migrate dir has been changed, run migrations and test db prepare
# in general, we need not to check schema despite the case that existing migration has
# been changed. It, most likely, will cause problems anyway
if [[ $dbtime != `stat -f "%m" db/migrate` || $schema != `stat -f "%m" db/schema.rb` ]]; then
echo "Starting migrations"
bundle exec rake db:migrate db:test:prepare
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment