changeset 4859:082027fb2d58

Allow "Measured" and "Forecast" values to coexist for the same time and gauge.
author Sascha Wilde <wilde@intevation.de>
date Wed, 04 Dec 2019 13:35:34 +0100
parents bf8fbb0fba52
children de7aa9230837
files schema/gemma.sql schema/updates/1315/01.extend_efa_primarykey.sql schema/version.sql
diffstat 3 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/schema/gemma.sql	Thu Nov 21 15:44:39 2019 +0100
+++ b/schema/gemma.sql	Wed Dec 04 13:35:34 2019 +0100
@@ -824,7 +824,8 @@
         fairway_availability_id int NOT NULL REFERENCES fairway_availability,
         measure_date timestamp with time zone NOT NULL,
         level_of_service smallint NOT NULL REFERENCES levels_of_service,
-        PRIMARY KEY (fairway_availability_id, measure_date, level_of_service),
+        PRIMARY KEY (fairway_availability_id, measure_date, level_of_service,
+                     measure_type),
         available_depth_value smallint,
         available_width_value smallint,
         water_level_value smallint,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/schema/updates/1315/01.extend_efa_primarykey.sql	Wed Dec 04 13:35:34 2019 +0100
@@ -0,0 +1,9 @@
+-- To allow "Measured" and "Forecast" values to coexist for the same
+-- time and gauge, the primary key must include the measure_type.
+
+ALTER TABLE waterway.effective_fairway_availability
+    DROP CONSTRAINT effective_fairway_availability_pkey;
+
+ALTER TABLE waterway.effective_fairway_availability
+    ADD PRIMARY KEY (fairway_availability_id, measure_date,
+                     level_of_service, measure_type);
--- a/schema/version.sql	Thu Nov 21 15:44:39 2019 +0100
+++ b/schema/version.sql	Wed Dec 04 13:35:34 2019 +0100
@@ -1,1 +1,1 @@
-INSERT INTO gemma_schema_version(version) VALUES (1314);
+INSERT INTO gemma_schema_version(version) VALUES (1315);