Automate the bundle/migration tedium of Rails with Git hooks
Hookup takes care of Rails tedium like bundling and migrating through Git hooks. It fires after events like
gem install hookup cd yourproject hookup install
Each time your current HEAD changes, hookup checks to see if your
Gemfile,
Gemfile.lock, or gem spec has changed. If so, it runs
bundle check, and if that indicates any dependencies are unsatisfied, it runs
bundle install.
Each time your current HEAD changes, hookup checks to see if any migrations have been added, deleted, or modified. Deleted and modified migrations are given the
rake db:migrate:downtreatment, then
rake db:migrateis invoked to bring everything else up to date.
Hookup provides a
-Coption to change to a specified directory prior to running
bundleor
rake. This should be used if your
Gemfileand
Rakefileare in a non-standard location.
To use a non-standard
dbdirectory (where
schema.rband
migrate/live), add
--schema-dir="database/path"to the
hookup post-checkoutline in
.git/hooks/post-checkout.
To force reloading the database if migrating fails, add
--load-schema="rake db:reset"to the
hookup post-checkoutline in
.git/hooks/post-checkout.
Each time there's a conflict in
db/schema.rbon the
Rails::Schema.defineline, hookup resolves it in favor of the newer of the two versions.
Set the
SKIP_HOOKUPenvironment variable to skip hookup.
SKIP_HOOKUP=1 git checkout master
hookup remove
Copyright (c) Tim Pope. MIT License.