awips2/deltaScripts/17.3.1/DR6065/6065_add_taf_queue_xml_column.sh
2022-05-05 12:34:50 -05:00

34 lines
948 B
Bash
Executable file

#!/bin/bash
# 6065 - This script creates the xml column on the taf_queue table.
#
# Author: tgurney
# Mar 22, 2017
psql=/awips2/psql/bin/psql
echo INFO: Adding xml column to taf_queue
exists=$(${psql} --user=awipsadmin --db=metadata -Atc "
select exists(
select 1 from information_schema.columns
where table_name = 'taf_queue'
and table_schema = 'awips'
and table_catalog = 'metadata'
and column_name = 'xml'
);")
if [[ "${exists}" == "f" ]]; then
${psql} --user=awipsadmin --db=metadata -Atc "
begin transaction;
alter table if exists taf_queue add column xml boolean not null default false;
alter table if exists taf_queue alter column xml drop default;
commit transaction;
"
elif [[ "${exists}" == "t" ]]; then
echo WARN: Column already exists. Doing nothing
else
echo ERROR: Failed to query the metadata database.
fi
echo INFO: Done.