awips2/deltaScripts/16.2.2/DR5254/alter_cwa_drop_datauri.sh
2022-05-05 12:34:50 -05:00

20 lines
588 B
Bash
Executable file

#!/bin/bash
# DR #5254 - This script drops dataURI column from cwa table and adds a new
# multi-column unique constraint
PSQL="/awips2/psql/bin/psql"
DBUSER=awips
echo "INFO: Altering table cwa"
${PSQL} -U ${DBUSER} -d metadata << EOF
begin transaction;
delete from cwa where eventid is null;
alter table cwa
drop constraint if exists uk_cwa_datauri_fields,
drop column if exists datauri,
alter eventid set not null,
add constraint uk_cwa_datauri_fields unique (reftime, forecasttime, eventid);
drop index if exists cwa_refTimeIndex;
commit transaction;
EOF