summaryrefslogtreecommitdiffstats
path: root/tools/dev_update_schema.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:40:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:40:59 +0000
commitbc4e624732bd51c0dd1e9529cf228e8c23127732 (patch)
treed95dab8960e9d02d3b95f8653074ad2e54ca207c /tools/dev_update_schema.sh
parentInitial commit. (diff)
downloadicingadb-bc4e624732bd51c0dd1e9529cf228e8c23127732.tar.xz
icingadb-bc4e624732bd51c0dd1e9529cf228e8c23127732.zip
Adding upstream version 1.1.1.upstream/1.1.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xtools/dev_update_schema.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/dev_update_schema.sh b/tools/dev_update_schema.sh
new file mode 100755
index 0000000..e1d08d6
--- /dev/null
+++ b/tools/dev_update_schema.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+set -e
+set -o pipefail
+
+cd "$(dirname "$0")"
+
+BASEDIR=".."
+
+test "$1" = '-f' || (
+ echo "Run '$0' -f to DROP ALL ICINGADB TABLES and re-create them using the current schema"
+ false
+)
+
+set -x
+
+(
+ mysql -uroot -e 'SHOW TABLES\G' icingadb </dev/null |\
+ ( grep -Ee '^Tables_in_icingadb: ' || true ) |\
+ cut -d ' ' -f 2 |\
+ perl -pe 's/^(.*?)$/DROP TABLE $1;/'
+
+ mysql -uroot -e 'SHOW PROCEDURE STATUS\G' icingadb </dev/null |\
+ ( grep -Ee '^ *Name: ' || true ) |\
+ cut -d ':' -f 2 |\
+ perl -pe 's/^ *(.*?)$/DROP PROCEDURE IF EXISTS $1;/'
+
+ cat $BASEDIR/etc/schema/mysql/{,helper/}*.sql
+
+ echo "GRANT ALL ON icingadb.* TO 'icingadb'@'127.0.0.1' IDENTIFIED BY 'icingadb';"
+) |mysql -uroot icingadb