Last active
February 26, 2016 14:56
-
-
Save xxswingxx/534839a9a21497bca3d4 to your computer and use it in GitHub Desktop.
Reset database after doing a checkout
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 | |
# Reset the database only if the previous branch and the current one have different schemas | |
# Start from the repository root. | |
cd ./$(git rev-parse --show-cdup) | |
if git diff `git rev-parse --abbrev-ref HEAD` @{-1} | grep "ActiveRecord::Schema.define(version: "; then | |
rake db:reset | |
else | |
echo "Skipping db reset: schema changes not found" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This git hook allows to automatically reload the schema if the previous branch and the current one have different schema.rb files