Skip to content

Instantly share code, notes, and snippets.

@towski
Last active August 29, 2015 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save towski/c5e77b7c334fae6907c6 to your computer and use it in GitHub Desktop.
Save towski/c5e77b7c334fae6907c6 to your computer and use it in GitHub Desktop.
rerun migration if the file is touched
# 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