Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/check-db-structure
blob: cb63c42180f2325258b79f594f222e117cf695ce (plain)
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/sh

# shellcheck source=../conf/default.conf
. "${0%/*}/../conf/default.conf"

# shellcheck disable=SC2016
{
  printf 'SELECT `proc`.`name` FROM `mysql`.`proc` WHERE `proc`.`Db`="buildmaster"' | \
    mysql_run_query | \
    while read -r procedure; do
      printf 'SHOW CREATE PROCEDURE `%s`;\n' "${procedure}"
    done
} | \
  mysql_run_query | \
  sed '
    s/ \(SELECT\|FROM\|\(LEFT \|RIGHT \)\?JOIN\|ON\|WHERE\) /\n\t\1 /g
    s/(SELECT/(\nSELECT/g
  '
# shellcheck disable=SC2016
{
  printf 'SHOW TABLES' | \
    mysql_run_query | \
    while read -r table; do
      printf 'SHOW CREATE TABLE `%s`;\n' "${table}"
    done
} | \
  mysql_run_query | \
  sed '
    s/ AUTO_INCREMENT=[0-9]\+ / /g
    s/^ /\t/
  '