diff schema/gemma.sql @ 5095:e21cbb9768a2

Prevent duplicate fairway areas In principal, there can be only one or no fairway area at each point on the map. Since polygons from real data will often be topologically inexact, just disallow equal geometries. This will also help to avoid importing duplicates with concurrent imports, once the history of fairway dimensions will be preserved.
author Tom Gottfried <tom@intevation.de>
date Wed, 25 Mar 2020 18:10:02 +0100
parents 8c590ef35280
children 882b3d2308c4
line wrap: on
line diff
--- a/schema/gemma.sql	Wed Mar 25 09:37:04 2020 +0100
+++ b/schema/gemma.sql	Wed Mar 25 18:10:02 2020 +0100
@@ -721,6 +721,9 @@
     CREATE TRIGGER fairway_dimensions_date_info
         BEFORE UPDATE ON fairway_dimensions
         FOR EACH ROW EXECUTE PROCEDURE update_date_info()
+    CREATE CONSTRAINT TRIGGER fairway_dimensions_area_unique
+        AFTER INSERT OR UPDATE OF area, staging_done ON fairway_dimensions
+        FOR EACH ROW EXECUTE FUNCTION prevent_st_equals('area', 'staging_done')
 
     --
     -- Bottlenecks