diff schema/gemma.sql @ 5016:cf25b23e3eec

Keep historic data of waterway axis ... and accordingly configure the respective layer as WMS-T.
author Tom Gottfried <tom@intevation.de>
date Fri, 13 Mar 2020 17:34:59 +0100
parents e8b2dc771f9e
children 737d7859dd86
line wrap: on
line diff
--- a/schema/gemma.sql	Fri Mar 13 14:13:32 2020 +0100
+++ b/schema/gemma.sql	Fri Mar 13 17:34:59 2020 +0100
@@ -624,11 +624,17 @@
             CHECK(ST_IsSimple(CAST(wtwaxs AS geometry))),
         -- TODO: Do we need to check data set quality (DRC 2.1.6)?
         objnam varchar NOT NULL,
-        nobjnam varchar
+        nobjnam varchar,
+        validity tstzrange NOT NULL DEFAULT tstzrange(current_timestamp, NULL)
+            CHECK (NOT isempty(validity)),
+        -- Last time an import job found this entry in a data source:
+        last_found timestamp with time zone NOT NULL DEFAULT current_timestamp
     )
     CREATE CONSTRAINT TRIGGER waterway_axis_wtwaxs_unique
-        AFTER INSERT OR UPDATE OF wtwaxs ON waterway_axis
-        FOR EACH ROW EXECUTE FUNCTION prevent_st_equals('wtwaxs')
+        AFTER INSERT OR UPDATE OF wtwaxs, validity ON waterway_axis
+        FOR EACH ROW EXECUTE FUNCTION prevent_st_equals('wtwaxs', 'validity')
+    CREATE INDEX waterway_axis_validity
+        ON waterway_axis USING GiST (validity)
 
     -- This table allows linkage between 1D ISRS location codes and 2D space
     -- e.g. for cutting bottleneck area out of waterway area based on virtual