awips2/deltaScripts/14.4.1/DR2587/nonNullTimes.sh
Nate Jensen 10e7afd1e8 Omaha #3299 delta script improvements
improvements based on discussions with Sean Webb

Change-Id: I5726a4c43b2b860f9fbc9e173cca5907d0a69c74

Former-commit-id: c57b4988b97327c1efa52383644913319eb0df74
2015-03-25 14:49:00 -05:00

18 lines
837 B
Bash
Executable file

#!/bin/bash
PSQL="/awips2/psql/bin/psql"
# vaa plugin was in rare occassions inserting records without a time which are then never purged
${PSQL} -U awips -d metadata -c "delete from vaa_location where parentid in (select recordid from vaa_subpart where parentid in (select id from vaa where reftime is NULL))"
${PSQL} -U awips -d metadata -c "delete from vaa_subpart where parentid in (select id from vaa where reftime is NULL)"
${PSQL} -U awips -d metadata -c "delete from vaa where reftime is NULL"
tables=$(psql -U awips -d metadata -tc "select table_name from information_schema.columns where column_name = 'reftime'")
echo "Updating record tables to disallow null times"
for table in $tables
do
echo "Updating $table"
psql -U awips -d metadata -c "ALTER TABLE $table ALTER COLUMN reftime SET NOT NULL"
done
echo "Done"