diff schema/gemma.sql @ 4967:3f704ebad0c5 fairway-marks-import

Follow-up of rev. 1b309a8e7673 for DAYMAR
author Tom Gottfried <tom@intevation.de>
date Fri, 28 Feb 2020 16:18:44 +0100
parents be713316b47a
children de190de05f67
line wrap: on
line diff
--- a/schema/gemma.sql	Fri Feb 28 13:51:55 2020 +0100
+++ b/schema/gemma.sql	Fri Feb 28 16:18:44 2020 +0100
@@ -1022,26 +1022,43 @@
 
     -- Additional attributes for IENC features DAYMAR/daymar
     CREATE TABLE fairway_marks_daymar (
-        id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
         colour varchar,
         colpat varchar,
         condtn int,
-        topshp int,
-        orient double precision
+        topshp int
     ) INHERITS (fairway_marks)
+
+    CREATE TABLE fairway_marks_daymar_hydro (
+        id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY
+    ) INHERITS (fairway_marks_daymar)
     -- Prevent identical entries using composite type comparison
     -- (i.e. considering two NULL values in a field equal):
-    CREATE UNIQUE INDEX fairway_marks_daymar_distinct_rows
-        ON fairway_marks_daymar
+    CREATE UNIQUE INDEX fairway_marks_daymar_hydro_distinct_rows
+        ON fairway_marks_daymar_hydro
         ((CAST((validity, last_found, geom,
                 datsta, datend, persta, perend, objnam, nobjnm, inform, ninfom,
                 scamin, picrep, txtdsc, sordat, sorind,
-                0, colour, colpat, condtn, topshp, orient
-            ) AS fairway_marks_daymar)
+                colour, colpat, condtn, topshp, 0
+            ) AS fairway_marks_daymar_hydro)
+        ))
+
+    CREATE TABLE fairway_marks_daymar_ienc (
+        orient double precision,
+        id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY
+    ) INHERITS (fairway_marks_daymar)
+    -- Prevent identical entries using composite type comparison
+    -- (i.e. considering two NULL values in a field equal):
+    CREATE UNIQUE INDEX fairway_marks_daymar_ienc_distinct_rows
+        ON fairway_marks_daymar_ienc
+        ((CAST((validity, last_found, geom,
+                datsta, datend, persta, perend, objnam, nobjnm, inform, ninfom,
+                scamin, picrep, txtdsc, sordat, sorind,
+                colour, colpat, condtn, topshp, orient, 0
+            ) AS fairway_marks_daymar_ienc)
         ))
 
     CREATE TABLE fairway_marks_daymar_dirimps (
-        fm_daymar_id int REFERENCES fairway_marks_daymar,
+        fm_daymar_id int REFERENCES fairway_marks_daymar_ienc,
         dirimp smallint REFERENCES dirimps,
         PRIMARY KEY (fm_daymar_id, dirimp)
     )