awips2/deltaScripts/future/alterTextProductsTables.sh
David Gillingham 84d7341a01 Issue #473: Properly archive text plugin records,
fix bugs in DatabaseArchiver.determineStartTime().

Change-Id: I2a7a71bcf7bdbc5ea786d949631b45342675ce1f

Former-commit-id: 8592a9a50d [formerly 526abfd36e] [formerly 8592a9a50d [formerly 526abfd36e] [formerly 04ab5d619b [formerly 6e45fc4f0eb15409a20be99c02b2ac43c8ed842e]]]
Former-commit-id: 04ab5d619b
Former-commit-id: cf74c74cc2 [formerly 36717c7a3e]
Former-commit-id: aeba62a5d9
2012-04-25 17:08:21 -05:00

18 lines
1.2 KiB
Bash

#!/bin/sh
# This script should be run on dx1 as part of next delivery to update the definitions for
# the stdtextproducts and practicestdtextproducts tables.
psql -U awips -d fxa -c "ALTER TABLE stdtextproducts RENAME COLUMN createtime to reftime;"
psql -U awips -d fxa -c "ALTER TABLE practicestdtextproducts RENAME COLUMN createtime to reftime;"
psql -U awips -d fxa -c "ALTER TABLE stdtextproducts ADD COLUMN inserttime timestamp without time zone;"
psql -U awips -d fxa -c "ALTER TABLE practicestdtextproducts ADD COLUMN inserttime timestamp without time zone;"
psql -U awips -d fxa -c "CREATE INDEX stdtextproductsinserttimeindex ON stdtextproducts USING btree (inserttime);"
psql -U awips -d fxa -c "CREATE INDEX practicestdtextproductsinserttimeindex ON practicestdtextproducts USING btree (inserttime);"
psql -U awips -d fxa -c "UPDATE stdtextproducts SET inserttime = CURRENT_TIMESTAMP AT TIME ZONE 'GMT' WHERE inserttime IS NULL;"
psql -U awips -d fxa -c "UPDATE practicestdtextproducts SET inserttime = CURRENT_TIMESTAMP AT TIME ZONE 'GMT' WHERE inserttime IS NULL;"
psql -U awips -d fxa -c "ALTER TABLE stdtextproducts ALTER COLUMN inserttime SET NOT NULL;"
psql -U awips -d fxa -c "ALTER TABLE practicestdtextproducts ALTER COLUMN inserttime SET NOT NULL;"