Custom post-checkout
git hook to auto rollback new migrations on git checkout
git config
is used to set rollback status
Backup existing post-checkout
hook
rails
npm >= 5.2.0
bash
$ npx auto-rollback enable
$ npx auto-rollback disable
$ npx auto-rollback status
After git checkout
:
- Execute
git checkout <previous-branch> db/migrate
- Get migration versions
- Execute
bundle exec rake db:migrate:down VERSION=<version>
for each version - Undo all changes in
db/migrate/
anddb/schema.rb
The flow will be less complicated if pre-checkout
git hook exist
- Assumes all migration are reversible
bundle exec rake db:migrate:down VERSION=<version>
fails silently
MIT