Merge "Omaha #3299 improved delta scripts from swebb" into omaha_14.4.1
Former-commit-id:bdb64e0c81
[formerly062758b071
[formerly b2a94f7fef07d801af86963abb8ac9eba328846b]] Former-commit-id:062758b071
Former-commit-id:9e502774f4
This commit is contained in:
commit
028ed81ee8
2 changed files with 14 additions and 5 deletions
|
@ -3,7 +3,12 @@
|
|||
# This script creates sequences for the tables in the events schema
|
||||
|
||||
STATS_MAX_VAL=$(psql -U awips -d metadata -t -c "select max(id)+1 from events.stats;")
|
||||
NOTIFICATION_MAX_VAL=$(psql -U awips -d metadata -t -c "select max(id)+1 from events.notification;")
|
||||
#Since events.notification will only exist at sites running datadelivery, check for table first to avoid ERRORs
|
||||
if [ `psql -U awips -d metadata -tAc "select exists (select 1 from information_schema.tables where table_schema='events' and table_name='notification');"` = 't' ]; then
|
||||
NOTIFICATION_MAX_VAL=$(psql -U awips -d metadata -t -c "select max(id)+1 from events.notification;")
|
||||
else
|
||||
NOTIFICATION_MAX_VAL=0
|
||||
fi
|
||||
AGGREGATE_MAX_VAL=$(psql -U awips -d metadata -t -c "select max(id)+1 from events.aggregate;")
|
||||
|
||||
if [ -z $STATS_MAX_VAL ]
|
||||
|
@ -23,6 +28,8 @@ fi
|
|||
|
||||
psql -U awips -d metadata -c \
|
||||
"CREATE SEQUENCE stats_seq START WITH $STATS_MAX_VAL; \
|
||||
CREATE SEQUENCE notification_seq START WITH $NOTIFICATION_MAX_VAL; \
|
||||
CREATE SEQUENCE aggregate_seq START WITH $AGGREGATE_MAX_VAL;"
|
||||
|
||||
if [ $NOTIFICATION_MAX_VAL != 0 ]; then
|
||||
psql -U awips -d metadata -c "CREATE SEQUENCE notification_seq START WITH $NOTIFICATION_MAX_VAL;"
|
||||
fi
|
||||
|
|
|
@ -11,7 +11,9 @@ function addNewTafColumns {
|
|||
echo "ALTER TABLE taf ADD COLUMN corindicator_temp boolean NOT NULL DEFAULT false;" >> $SQL_FILE
|
||||
echo "ALTER TABLE taf ADD COLUMN amdindicator_temp boolean NOT NULL DEFAULT false;" >> $SQL_FILE
|
||||
echo "UPDATE taf set corindicator_temp = true where corindicator = 'COR';" >> $SQL_FILE
|
||||
echo "UPDATE taf set corindicator_temp = true where corindicator = 'true';" >> $SQL_FILE
|
||||
echo "UPDATE taf set amdindicator_temp = true where amdindicator = 'AMD';" >> $SQL_FILE
|
||||
echo "UPDATE taf set amdindicator_temp = true where amdindicator = 'true';" >> $SQL_FILE
|
||||
|
||||
${PSQL} -U awips -d metadata -f $SQL_FILE
|
||||
if [ $? -ne 0 ]; then
|
||||
|
@ -33,7 +35,7 @@ function deleteTafData {
|
|||
temp="_temp"
|
||||
fi
|
||||
|
||||
query="SELECT distinct b.id FROM taf a, taf b WHERE (a.reftime = b.reftime AND a.stationid = b.stationid AND a.corindicator$temp = b.corindicator$temp AND a.amdindicator$temp = b.amdindicator$temp AND a.issue_timestring = b.issue_timestring AND a.inserttime < b.inserttime) or (b.reftime isnull) or (b.stationid isnull) or (b.issue_timestring isnull)"
|
||||
query="SELECT distinct b.id FROM taf a, taf b WHERE (a.reftime = b.reftime AND a.stationid = b.stationid AND a.corindicator$temp = b.corindicator$temp AND a.amdindicator$temp = b.amdindicator$temp AND a.issue_timestring = b.issue_timestring AND ((a.inserttime < b.inserttime) or (a.inserttime = b.inserttime and a.id < b.id))) or (b.reftime isnull) or (b.stationid isnull) or (b.issue_timestring isnull)"
|
||||
|
||||
echo " INFO: Finding taf entries to delete"
|
||||
result=(`${PSQL} -U awips -d metadata -t -A -c "$query"`)
|
||||
|
@ -51,10 +53,10 @@ function deleteTafData {
|
|||
fi
|
||||
|
||||
# handle cascade tables
|
||||
query="SELECT distinct id from taf_change_groups where parentid in ($taf_ids)"
|
||||
echo "SELECT distinct id from taf_change_groups where parentid in ($taf_ids)" > $SQL_FILE
|
||||
|
||||
echo " INFO: Finding cascaded taf_change_group entries"
|
||||
result=(`${PSQL} -U awips -d metadata -t -A -c "$query"`)
|
||||
result=(`${PSQL} -U awips -d metadata -t -A -f $SQL_FILE`)
|
||||
|
||||
numEntries="${#result[@]}"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue