diff schema/gemma.sql @ 3171:c8ded555c2a8

Sections import: Added a sections import. Derived from the stretches import w/o the countries.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 06 May 2019 16:36:03 +0200
parents f394e828a6d2
children 1cb6676d1510
line wrap: on
line diff
--- a/schema/gemma.sql	Mon May 06 16:18:41 2019 +0200
+++ b/schema/gemma.sql	Mon May 06 16:36:03 2019 +0200
@@ -406,6 +406,24 @@
         UNIQUE(stretches_id, country_code)
     )
 
+    -- Like stretches without the countries
+    CREATE TABLE sections (
+        id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
+        name varchar NOT NULL,
+        stretch isrsrange NOT NULL,
+        area geography(MULTIPOLYGON, 4326) NOT NULL
+            CHECK(ST_IsValid(CAST(area AS geometry))),
+        objnam varchar NOT NULL,
+        nobjnam varchar,
+        date_info timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
+        source_organization varchar NOT NULL,
+        staging_done boolean NOT NULL DEFAULT false,
+        UNIQUE(name, staging_done)
+    )
+    CREATE TRIGGER sections_date_info
+        BEFORE UPDATE ON stretches
+        FOR EACH ROW EXECUTE PROCEDURE update_date_info()
+
     CREATE TABLE waterway_profiles (
         id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
         location isrs NOT NULL REFERENCES distance_marks_virtual,