I saw Scott Bellware recently write on twitter: for christmas, i really want a git hook to detect if an update has changes in the db/migrations folder
Cory Foy, Aaron Jensen, and myself all responded in turn.
I think Cory and I were quickly searching for which git hook could be used for this idea. Cory found it first and it was the post-merge/post-rebase hooks. I researched the post-merge hook (scroll down to post-merge) and noticed it has no params that we could work with to find out if the last commit had migrations (aka changes/additions to db/migrations folder in a rails project)
I came up with the following :
This will grab the previous diff and look for “db/migrations” in the text. If it’s present, it would auto-run “rake db:migrate && rake db:test:migrate”. In other words, it will migrate the development database schema, then the test database schema.
Post Footer automatically generated by Add Post Footer Plugin for wordpress.

Thanks, Jason!
Hi, Looks like this only works if the pull contains 1 commit, if it has many commits, if the latest commit doesn’t have something on migrations, it doesn’t do nothing.
you can tweak it with git diff –name-only HEAD@{1} HEAD instead of git diff HEAD^
Thank you Marcelo. Post updated.