awips2/deltaScripts/14.4.1/DR3392/changeAcarsDoubleToReal.sh
Nathan Bowler 4f3a729894 Omaha #3392 Change Doubles to Float in ACARS and ACARSSoundingLayer
Change-Id: I6c07c51a3118d6317418a22be56b7899734e5917

Former-commit-id: 9ac070996c42b004f3683d7ee253feb54f05264c
2014-07-22 14:05:16 -04:00

30 lines
803 B
Bash
Executable file

#!/bin/bash
# DR #3392 - this update script will change columns from Double to Real
TABLES=(acars acarssoundinglayer)
COLUMNS=(dwpt humidity mixingratio pressure temp windspeed)
PSQL="/awips2/psql/bin/psql"
# takes two args: a table name and a column name
# alters the column in the table to real
function changeToReal {
echo "INFO: Changing table $1 column $2 to real."
${PSQL} -U awips -d metadata -c "ALTER TABLE $1 ALTER COLUMN $2 TYPE real;"
if [ $? -ne 0 ]; then
echo "ERROR: Failed to change the column $2 for table $1"
echo "FATAL: The update has failed."
exit 1
fi
}
for table in ${TABLES[*]}
do
echo "INFO: Altering table $table."
for column in ${COLUMNS[*]}
do
changeToReal $table $column
done
done
echo "INFO: All columns changed successfully"