-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff-db.sh
More file actions
executable file
·47 lines (35 loc) · 1.09 KB
/
diff-db.sh
File metadata and controls
executable file
·47 lines (35 loc) · 1.09 KB
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
#!/bin/bash
# Diffs the DB schema of the 2 specified (old, new) environments. The result is
# written to the stdout.
# TODO matej Rename to db-schema-diff
# full path to this script
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${DIR}/conf/config.sh"
source "${DIR}/utils/utils.sh"
source "${DIR}/utils/db-utils.sh"
function main {
if [[ "${#}" != "2" ]]
then
echo "2 parameters expected: oldenvironment newenvironment"
exit 1
fi
ENV1="${1}"
ENV2="${2}"
# TODO check the environment specifications were correct
# TODO move somehow to config
WORK="${DIR}/work"
mkdir -p "${WORK}"
DIFF="${DIR}/apgdiff/apgdiff-2.4.jar"
OLD_SQL="${WORK}/${ENV1}-schema.sql"
NEW_SQL="${WORK}/${ENV2}-schema.sql"
db_download_schema "${ENV1}" "${OLD_SQL}" "${PG_DUMP}"
db_download_schema "${ENV2}" "${NEW_SQL}" "${PG_DUMP}"
if [[ ! -f "${OLD_SQL}" || ! -f "${NEW_SQL}" ]]
then
echo "Getting one or both of schemas failed."
exit 1
fi
java -jar "${DIFF}" "${OLD_SQL}" "${NEW_SQL}"
}
main "${@}"
exit 0