Former-commit-id:196767d525
[formerlydc9fef33a9
] [formerly9be238bcc4
] [formerly196767d525
[formerlydc9fef33a9
] [formerly9be238bcc4
] [formerlyabaf9f12f9
[formerly9be238bcc4
[formerly ce855032b2b7235b2aea8dc66aff89ca7c54854a]]]] Former-commit-id:abaf9f12f9
Former-commit-id:fe5020d315
[formerlyed4150db5f
] [formerly afa8971d2a4b49801835997c9e04d909cbb5917c [formerly340a2cfb23
]] Former-commit-id: 8178539bb83f1e27afa01a5dd82705a3f18fc420 [formerly7d76371536
] Former-commit-id:7b7efd0bd1
33 lines
908 B
Bash
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
|