awips2/deltaScripts/13.3.1/removeDataURIIndex.sh
Steve Harris b6db7821fa 13.3.1-19 baseline
Former-commit-id: 196767d525 [formerly dc9fef33a9] [formerly 9be238bcc4] [formerly 196767d525 [formerly dc9fef33a9] [formerly 9be238bcc4] [formerly abaf9f12f9 [formerly 9be238bcc4 [formerly ce855032b2b7235b2aea8dc66aff89ca7c54854a]]]]
Former-commit-id: abaf9f12f9
Former-commit-id: fe5020d315 [formerly ed4150db5f] [formerly afa8971d2a4b49801835997c9e04d909cbb5917c [formerly 340a2cfb23]]
Former-commit-id: 8178539bb83f1e27afa01a5dd82705a3f18fc420 [formerly 7d76371536]
Former-commit-id: 7b7efd0bd1
2013-04-09 08:37:12 -05:00

33 lines
908 B
Bash

#!/bin/bash
# DR #1846 - this update script will remove all datauri_idx indices from the metadata database
PSQL="/awips2/psql/bin/psql"
RETRIEVE_INDEX_SQL="SELECT indexname FROM pg_indexes WHERE indexname LIKE '%datauri_idx%' ORDER BY indexname;"
_index_list_txt=indexlist.txt
echo "INFO: update started"
# retrieve the indices
${PSQL} -U awips -d metadata -c "${RETRIEVE_INDEX_SQL}" -t -o ${_index_list_txt}
if [ $? -ne 0 ]; then
echo "ERROR: Failed to retrieve the list of data uri indices."
echo "FATAL: The update has failed."
exit 1
fi
for index in `cat ${_index_list_txt}`;
do
# remove the index
${PSQL} -U awips -d metadata -c "DROP INDEX ${index};"
if [ $? -ne 0 ]; then
echo "ERROR: Failed to drop index - ${index}."
echo "FATAL: The update has failed."
exit 1
fi
done
rm -f ${_index_list_txt}
echo "INFO: the update has completed successfully!"
exit 0