Last active
August 29, 2015 14:07
-
-
Save towski/c5e77b7c334fae6907c6 to your computer and use it in GitHub Desktop.
rerun migration if the file is touched
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
# if your db is currently up to date, just run make setup to touch all the files. otherwise start the db from scratch | |
MIGRATIONS = $(shell ls db/migrate) | |
RUN_FILES = $(addprefix db/run/,$(MIGRATIONS)) | |
all: db/run release | |
release: | |
$(MAKE) migrate | |
$(MAKE) db/run/tests_updated | |
db/run: | |
mkdir -p db/run | |
migrate: $(RUN_FILES) | |
db/run/tests_updated: db/run/update_test | |
rake db:test:clone | |
touch db/run/tests_updated | |
db/run/%: db/migrate/% | |
$(eval VERSION = $(patsubst db/migrate/%,%,$<)) | |
rake db:migrate:down db:migrate:up VERSION=$(VERSION) --trace | |
touch db/run/$(VERSION) | |
touch db/run/update_test | |
clean: | |
rm db/run/* | |
setup: db/run | |
$(shell ls db/migrate | xargs -I {} touch db/run/{}) | |
touch db/run/update_test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment