# HG changeset patch # User Sascha Wilde # Date 1575462934 -3600 # Node ID 082027fb2d58d333bddd86b8f002b46df886a919 # Parent bf8fbb0fba52304a6518b7209a9f5f5ba2ba0120 Allow "Measured" and "Forecast" values to coexist for the same time and gauge. diff -r bf8fbb0fba52 -r 082027fb2d58 schema/gemma.sql --- 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, diff -r bf8fbb0fba52 -r 082027fb2d58 schema/updates/1315/01.extend_efa_primarykey.sql --- /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); diff -r bf8fbb0fba52 -r 082027fb2d58 schema/version.sql --- 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);