Skip to content

Instantly share code, notes, and snippets.

@wojtekmach
Last active February 3, 2016 10:52
Show Gist options
  • Save wojtekmach/d57942eb13b055e89098 to your computer and use it in GitHub Desktop.
Save wojtekmach/d57942eb13b055e89098 to your computer and use it in GitHub Desktop.
#!/bin/bash
# This scripts re-runs all migrations in test DB
# and reports (along with exist status 1) any
# not commited changes to schema.rb.
#
# It's best to run this script on CI and fail the build
# because it means there's a discrepancy between migrations
# and schema.rb. (e.g. someone changed migration inline
# but forgot to redo the migration and update schema.rb.)
RAILS_ENV=test rake db:migrate:reset
if ! git diff --quiet db/schema.rb; then
echo "Found not committed changes to schema.rb! See below:"
git diff db/schema.rb
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment