awips2/deltaScripts/13.4.1/removeHdffileidColumn.sh
Steve Harris f95e0ad10b 13.4.1-1 baseline
Former-commit-id: 00332e6305 [formerly c03222bb480d87c05982b4d49f863e615b5b5584]
Former-commit-id: 2f517b7713
2013-04-24 17:15:55 -05:00

35 lines
900 B
Bash

#!/bin/bash
#!/bin/bash
# DR #1846 - this update script will remove all hdffileid columns from the metadata database
PSQL="/awips2/psql/bin/psql"
SQL="SELECT table_name FROM information_schema.columns WHERE column_name = 'hdffileid';"
_table_list_txt=tablelist.txt
echo "INFO: update started."
# retrieve the tables
${PSQL} -U awips -d metadata -c "${SQL}" -t -o ${_table_list_txt}
if [ $? -ne 0 ]; then
echo "ERROR: Failed to retrieve the list of tables."
echo "FATAL: The update has failed."
exit 1
fi
for table in `cat ${_table_list_txt}`;
do
${PSQL} -U awips -d metadata -c "ALTER TABLE ${table} DROP COLUMN hdffileid CASCADE;"
if [ $? -ne 0 ]; then
echo "ERROR: Failed to drop column hdffileid in table ${table}."
echo "FATAL: The update has failed."
exit 1
fi
done
rm -f ${_table_list_txt}
echo "INFO: the update has completed successfully!"
exit 0