blob: 436ce00cde7137e458183b141957cbd59f79d7a1 (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#!/bin/sh
# shellcheck disable=SC2119,SC2120
# shellcheck source=../lib/load-configuration
. "${0%/*}/../lib/load-configuration"
# stored functions
# 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
'
# table headers
# 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/
'
# content of "constant" tables
mysqldump --skip-lock-tables 'buildmaster' \
'architectures' \
'dependency_types' \
'email_actions' \
'fail_reasons' \
'repositories' \
'repository_moves' \
'repository_stabilities' \
'repository_stability_relations' \
'upstream_repositories' | \
grep '^INSERT ' | \
tr '\0\1' '01' | \
sed '
s/),(/),\n (/g
s/VALUES (/VALUES\n (/g
'
|