-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathgenerate_db_schema_doc.sh
executable file
·60 lines (49 loc) · 1.81 KB
/
generate_db_schema_doc.sh
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
57
58
59
60
#!/usr/bin/env bash
# Copyright 2021 Red Hat, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Script to generate documentation with DB schema description
function cleanUpAndExit {
if [[ $DB_KEEP_RUNNING == 0 ]]; then
podman stop $DB_POD_NAME
fi
exit $1
}
# Settings for database to be documented
# (can be taken from config.toml, config-devel.toml etc.)
DB_ADDRESS=localhost
DB_LOGIN=postgres
DB_PASSWORD=postgres
DB_NAME=aggregator
DB_POD_NAME=postgres_aggregator
DB_KEEP_RUNNING=1
# Generate the documentation
OUTPUT_DIR=docs/db-description
# Launch local postgres from scratch
if ! podman run --name=$DB_POD_NAME --rm --network=host -e POSTGRES_PASSWORD=$DB_PASSWORD -e POSTGRES_USER=$DB_LOGIN -e POSTGRES_DB=$DB_NAME -d postgres:10; then
echo "Cannot launch postgress database locally"
cleanUpAndExit 1
fi
# Run migration to latest
if ! make; then
echo "Cannot build aggregator"
cleanUpAndExit 2
fi
sleep 5
export INSIGHTS_RESULTS_AGGREGATOR_CONFIG_FILE=./config-devel.toml
if ! ./insights-results-aggregator migration latest; then
echo "Failure generating latest migration"
cleanUpAndExit 3
fi
java -jar schemaspy-6.1.0.jar -cp . -t pgsql -u ${DB_LOGIN} -p ${DB_PASSWORD} -host ${DB_ADDRESS} -s public -o ${OUTPUT_DIR} -db ${DB_NAME} -dp postgresql-42.2.20.jre7.jar
cleanUpAndExit $?