Change-Id: Ie3e8b595cf67c6d30047d74e689b2cf9bcd31bea Former-commit-id:31a84fb91f
[formerlyc63a4882e7
] [formerly99391cfe12
] [formerly31a84fb91f
[formerlyc63a4882e7
] [formerly99391cfe12
] [formerlyd4135dba62
[formerly99391cfe12
[formerly 883a51484d03900852ed84820aa559e088c97335]]]] Former-commit-id:d4135dba62
Former-commit-id:2813a8fc47
[formerly43a90c062c
] [formerly adfd41ab237c568aeecc21759b668b8afa0b7822 [formerlya02955e40c
]] Former-commit-id: a8522f4158313026efd8946f1eccafa6f78a6ff3 [formerly81ece036ac
] Former-commit-id:fe2e894307
75 lines
2.1 KiB
Bash
75 lines
2.1 KiB
Bash
#!/bin/bash
|
|
# Main script for updating warning database structure
|
|
|
|
PSQL="/awips2/psql/bin/psql"
|
|
PYTHON="/awips2/python/bin/python"
|
|
|
|
SQL_SCRIPT="alterWarningTables.sql"
|
|
|
|
# ensure that the sql script is present
|
|
if [ ! -f ${SQL_SCRIPT} ]; then
|
|
echo "ERROR: the required sql script - ${SQL_SCRIPT} was not found."
|
|
echo "FATAL: the update has failed!"
|
|
exit 1
|
|
fi
|
|
|
|
|
|
echo "Adding ugczones column to warning tables"
|
|
${PSQL} -U awips -d metadata -f ${SQL_SCRIPT}
|
|
if [ $? -ne 0 ]; then
|
|
echo "FATAL: the update has failed!"
|
|
exit 1
|
|
fi
|
|
|
|
TABLES="practicewarning warning"
|
|
for table in $TABLES
|
|
do
|
|
echo
|
|
echo "Querying for $table ugc zones"
|
|
RETRIEVE_UGC_ZONES_SQL="SELECT parentwarning, zone FROM warning_ugczone where parentwarning in (select id from $table) order by parentwarning, key"
|
|
_ugc_zone_txt="${table}UgcZones.txt"
|
|
|
|
${PSQL} -U awips -d metadata -c "${RETRIEVE_UGC_ZONES_SQL}" -t -o ${_ugc_zone_txt}
|
|
if [ $? -ne 0 ]; then
|
|
echo "ERROR: Failed to retrieve the ugc zones for $table table."
|
|
echo "FATAL: The update has failed."
|
|
exit 1
|
|
fi
|
|
|
|
echo
|
|
echo "Parsing ugc zones for insertion into $table table"
|
|
PYTHON_PARSE_SCRIPT="parseUgcZones.py"
|
|
if [ ! -f ${PYTHON_PARSE_SCRIPT} ]; then
|
|
echo "ERROR: the required python script - ${PYTHON_PARSE_SCRIPT} was not found."
|
|
echo "FATAL: the update has failed!"
|
|
exit 1
|
|
fi
|
|
|
|
${PYTHON} ${PYTHON_PARSE_SCRIPT} ${table} ${_ugc_zone_txt}
|
|
if [ $? -ne 0 ]; then
|
|
echo "ERROR: Failed to parse ugc zones."
|
|
echo "FATAL: The update has failed."
|
|
exit 1
|
|
fi
|
|
|
|
echo
|
|
echo "Adding ugc zones to $table table"
|
|
# ${table}UgcZonesUpdates.sql generated from parseParmIds.py
|
|
${PSQL} -U awips -d metadata -q -f ${table}UgcZonesUpdates.sql
|
|
if [ $? -ne 0 ]; then
|
|
echo "ERROR: Failed to add ugc zones."
|
|
echo "FATAL: The update has failed."
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
#remove warning_ugczone
|
|
echo
|
|
echo "Dropping warning_ugczone table"
|
|
DROP_TABLE_SQL="DROP TABLE warning_ugczone"
|
|
|
|
${PSQL} -U awips -d metadata -c "${DROP_TABLE_SQL}"
|
|
|
|
echo
|
|
echo "Running full vacuum for warning"
|
|
${PSQL} -U awips -d metadata -c "VACUUM FULL VERBOSE ANALYZE warning"
|