changeset 92:f11366b419ae

Fix profile constraints.
author Tom Gottfried <tom@intevation.de>
date Fri, 01 Jun 2018 20:08:47 +0200
parents c38edd879e2e
children 765906789840
files wamos.sql
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/wamos.sql	Fri Jun 01 19:50:58 2018 +0200
+++ b/wamos.sql	Fri Jun 01 20:08:47 2018 +0200
@@ -196,7 +196,7 @@
 
 CREATE TABLE wamos_waterway.waterway_profiles (
        location isrs NOT NULL,
-       validity tstzrange NOT NULL,
+       validity tstzrange,
        EXCLUDE USING GIST (validity WITH &&),
        PRIMARY KEY (location, validity),
        lnwl smallint,
@@ -204,6 +204,9 @@
        hnwl smallint,
        fe30 smallint,
        fe100 smallint,
+       -- XXX: further normalise using reference_water_levels?
+       CHECK(COALESCE(lnwl, mwl, hnwl, fe30, fe100) IS NULL
+             OR validity IS NOT NULL),
        date_info timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
        source_organization varchar NOT NULL
        );