summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-08-07 01:04:33 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-08-07 01:04:33 +0100
commit05797e3165a810ff653cc62a10b2481adc62621b (patch)
treece6a48fdcc121b0a58dd93ad8940e205356ad2c5
parentRemove blank and -- lines (diff)
downloadgentoobrowse-05797e3165a810ff653cc62a10b2481adc62621b.tar.bz2
gentoobrowse-05797e3165a810ff653cc62a10b2481adc62621b.tar.xz
gentoobrowse-05797e3165a810ff653cc62a10b2481adc62621b.zip
Schema tools
-rw-r--r--gentoobrowse/.gitignore2
-rw-r--r--gentoobrowse/datasources/database.mk11
-rw-r--r--gentoobrowse/datasources/schema.mk5
3 files changed, 18 insertions, 0 deletions
diff --git a/gentoobrowse/.gitignore b/gentoobrowse/.gitignore
new file mode 100644
index 0000000..0fae0f4
--- /dev/null
+++ b/gentoobrowse/.gitignore
@@ -0,0 +1,2 @@
+datasources/current.sql
+datasources/patch.sql
diff --git a/gentoobrowse/datasources/database.mk b/gentoobrowse/datasources/database.mk
new file mode 100644
index 0000000..0d242d0
--- /dev/null
+++ b/gentoobrowse/datasources/database.mk
@@ -0,0 +1,11 @@
+.PHONY : database current.sql schema.sql
+
+database: patch.sql
+ psql -U gentoo gentoo -qf $<
+
+current.sql :
+ pg_dump -U gentoo gentoo -n gentoobrowse -s -E utf8 | grep -v _gentoo > $@
+
+patch.sql : current.sql schema.sql
+ apgdiff --add-transaction current.sql schema.sql | tee $@
+
diff --git a/gentoobrowse/datasources/schema.mk b/gentoobrowse/datasources/schema.mk
new file mode 100644
index 0000000..42d4586
--- /dev/null
+++ b/gentoobrowse/datasources/schema.mk
@@ -0,0 +1,5 @@
+.PHONY : schema.sql
+
+schema.sql :
+ pg_dump -U gentoo gentoo -n gentoobrowse -s -E utf8 | grep -v _gentoo | grep -v '^\(--\|\)$$' > $@
+