简体   繁体   中英

How to notified about pending Rails migrations after git pull?

I think everybody had that problem. When you colleague creates a migration and you forget to run it after git pull . As I understand, this can be done by post-checkout git hook. Is there a ready solution?

If not, suggest how to make this check. Simple solution is to run rake db:abort_if_pending_migrations in git hook, but it will be too slow.

I've done a gist with ruby code that does that check. It's useful to execute it at post-merge and post-checkout hooks.

The main idea is to diff current head with previous head state (HEAD@{1} , which is state before git pull) and search if there was any changes in db/migrate folder.

Thanks to Shadwell for finding almost working solution which I forked.

I found this post that has a ruby script and steps to follow to get it running. It looks like it will do what you want, and will optionally run the migrations too. It does it by checking for changes in the db/migrate folder. It does it as a post-merge hook.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM