aboutsummaryrefslogtreecommitdiff
path: root/db/makefile
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-05-08 12:39:19 +0200
committerlonkaars <loek@pipeframe.xyz>2023-05-08 12:39:19 +0200
commit25b6b8926d8cb3c4cabc8e7764e613d3bb4e4ed7 (patch)
treef53a14278d32e1986cb7e323e886bebafb50905f /db/makefile
parentc4acffbebf278a07fbe82c9f1c09b73cd5d00086 (diff)
add database init sql scripts
Diffstat (limited to 'db/makefile')
-rw-r--r--db/makefile35
1 files changed, 35 insertions, 0 deletions
diff --git a/db/makefile b/db/makefile
new file mode 100644
index 0000000..0802fa6
--- /dev/null
+++ b/db/makefile
@@ -0,0 +1,35 @@
+SQL = mysql
+USER = $(shell id -un)
+HOST = localhost
+
+.PHONY: clean permissions base data full
+
+all: full
+
+# delete old tables and create new tables
+base: base.sql
+ $(SQL) < $<
+
+# fill tables with data
+data: data.sql
+ $(SQL) < $<
+
+# do everything
+full: full.sql
+ $(SQL) < $<
+
+base.sql: reset.sql init.sql
+ cat $^ > $@
+
+full.sql: base.sql data.sql
+ cat $^ > $@
+
+# grant all database permissions to current user (development only)
+permissions:
+ echo "grant all privileges on webs.* to '$(USER)'@'$(HOST)';" | sudo $(SQL)
+# echo "grant file on *.* to '$(USER)'@'$(HOST)';" | sudo $(SQL)
+
+# delete generated sql files
+clean:
+ $(RM) full.sql base.sql
+