diff schema/gemma.sql @ 4673:443867b548b5

Fix identifiers in layers generated from SQL views
author Tom Gottfried <tom@intevation.de>
date Tue, 15 Oct 2019 15:59:38 +0200
parents 66fcd898efd9
children 9279fdb7a422
line wrap: on
line diff
--- a/schema/gemma.sql	Tue Oct 15 15:55:12 2019 +0200
+++ b/schema/gemma.sql	Tue Oct 15 15:59:38 2019 +0200
@@ -388,6 +388,8 @@
         PRIMARY KEY (schema, name),
         -- SQL statement used for an SQL view in GeoServer:
         view_def text CHECK (is_valid_from_item(view_def)),
+        -- Column in output of SQL statement to be used as primary key:
+        key_column varchar,
         -- SRID to be used with SQL view:
         srid int REFERENCES spatial_ref_sys,
         -- SLD style document:
@@ -577,23 +579,6 @@
         related_enc varchar(12)
     )
 
-    -- We need to configure primary keys for the views used by
-    -- geoserver for wfs, otherwise it will generate ids on the fly,
-    -- which will change for the same feature...
-    -- See
-    -- https://docs.geoserver.org/stable/en/user/data/database/primarykey.html
-    -- for details.
-    CREATE TABLE gt_pk_metadata (
-        table_schema VARCHAR(32) NOT NULL,
-        table_name VARCHAR(32) NOT NULL,
-        pk_column VARCHAR(32) NOT NULL,
-        pk_column_idx INTEGER,
-        pk_policy VARCHAR(32),
-        pk_sequence VARCHAR(64),
-        unique (table_schema, table_name, pk_column),
-        check (pk_policy in ('sequence', 'assigned', 'autogenerated'))
-    )
-
     -- Like stretches without the countries
     CREATE TABLE sections (
         id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
@@ -802,14 +787,6 @@
     )
 ;
 
--- Configure primary keys for geoserver views
-INSERT INTO waterway.gt_pk_metadata VALUES
-  ('waterway', 'gauges_geoserver', 'isrs_code'),
-  ('waterway', 'distance_marks_geoserver', 'location'),
-  ('waterway', 'distance_marks_ashore_geoserver', 'id'),
-  ('waterway', 'bottlenecks_geoserver', 'id'),
-  ('waterway', 'stretches_geoserver', 'id'),
-  ('waterway', 'sections_geoserver', 'id');
 
 --
 -- Import queue and respective logging