File: dev_update_schema.sh

package info (click to toggle)
icingadb 1.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 59,960 kB
  • sloc: ansic: 170,157; asm: 7,097; sql: 4,098; sh: 1,614; cpp: 1,132; makefile: 438; xml: 160
file content (31 lines) | stat: -rwxr-xr-x 708 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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