Last active
August 29, 2015 14:03
-
-
Save stilliard/c2cf024c9552415b1b49 to your computer and use it in GitHub Desktop.
Git checkout and auto ruckusing migrations and composer composer setup!
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
git config alias.migrate-to '!f() { make checkout BRANCH=$1; }; f' |
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
# | |
# Chekout branch in git and run migrations down and up | |
# | |
checkout: | |
ifeq ($(BRANCH),) | |
@echo "\nPlease specify branch, e.g. make checkout BRANCH=master\n" | |
else | |
$(eval old_id = $(shell git diff $(BRANCH) --name-status -- migrations | grep '^A' | head -n1 | grep -oP '(\d+)(?=_)')) | |
@echo "Checking for any migrations needed to be rolled back" | |
@if [[ "$(old_id)" != "" ]]; then \ | |
echo "Migrating down..."; \ | |
php vendor/bin/ruckus.php db:migrate VERSION=$$(ls migrations/default/ | grep -B 1 $(old_id) | head -n 1 | grep -oP '(\d+)(?=_)'); \ | |
fi; | |
git checkout $(BRANCH) | |
make update --no-print-directory | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment