diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-03-07 19:50:24 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-03-07 20:12:44 +0100 |
commit | 2528bcaf1f76e4a6c40c6aa4d6c72a16d37f9177 (patch) | |
tree | a815537a3b3708491b61f30b2dfa7ade21d44e90 /dbinit/makefile | |
parent | ee88077eb90bc7f7f800fa04e78bf055fc552cd9 (diff) |
WIP import script
Diffstat (limited to 'dbinit/makefile')
-rw-r--r-- | dbinit/makefile | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/dbinit/makefile b/dbinit/makefile index d6ab70e..0e335b7 100644 --- a/dbinit/makefile +++ b/dbinit/makefile @@ -1,5 +1,39 @@ -dbinit.sql: base.sql data.sql +SQL = mysql +USER = $(shell id -un) +HOST = localhost + +.PHONY: clean permissions init data procedures full + +# delete old tables and create new tables +init: base.sql + $(SQL) < $< + +# fill tables with data +data: data.sql + $(SQL) < $< + +# add procedures/sql functions +procedures: procedures.sql + $(SQL) < $< + +# do all of the above in one go +full: full.sql + $(SQL) < $< + +base.sql: reset.sql init.sql + cat $^ > $@ + +full.sql: reset.sql init.sql data.sql procedures.sql cat $^ > $@ data.sql: ./import.py > $@ + +# grant all database permissions (development only) +permissions: + echo "grant all privileges on formula1.* to '$(USER)'@'$(HOST)';" | sudo $(SQL) + +# delete generated sql files +clean: + $(RM) full.sql base.sql data.sql + |