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

Former-commit-id: 46b40bd411 [formerly 7d352f77a3] [formerly 06b9d253f3] [formerly 46b40bd411 [formerly 7d352f77a3] [formerly 06b9d253f3] [formerly 4f3a729894 [formerly 06b9d253f3 [formerly 9ac070996c42b004f3683d7ee253feb54f05264c]]]]
Former-commit-id: 4f3a729894
Former-commit-id: bf879fbbe6 [formerly 0067bc04d3] [formerly d8ef0e2fcbc02ecfccf18fc91e0e1d4750c34c9f [formerly 085fe0e479]]
Former-commit-id: d4ea97d224890b5ca76007f71724a313d0ab5f50 [formerly 0bfeb9fd7f]
Former-commit-id: d49ed2283d
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"