Last active
June 29, 2019 01:01
-
-
Save markusfisch/889657 to your computer and use it in GitHub Desktop.
Makefile to generate create/drop/recreate scripts from a bunch of SQL files
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
CREATE=create.sql | |
DROP=drop.sql | |
RECREATE=recreate.sql | |
all: recreate | |
recreate: clean create drop | |
cat $(DROP) $(CREATE) > $(RECREATE) | |
create: | |
rm -f $(CREATE) | |
grep -Evh "^[ ]*[/*]+" *.sql > $(CREATE) | |
drop: | |
egrep "(CREATE TABLE)" $(CREATE) | tac | \ | |
sed -e "s_CREATE_DROP_g;s_\$$_;_g" > $(DROP) | |
clean: | |
rm -f $(CREATE) $(DROP) $(RECREATE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment