Mercurial > gemma
changeset 1446:1e19184472bf
Add configuration of primary key metadata used by geoserver.
This fixes the duplication of distance marks, when navigating on the map.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Fri, 30 Nov 2018 15:56:34 +0100 |
parents | a1bff497d4aa |
children | 6f2219d942d6 |
files | pkg/geoserver/boot.go schema/gemma.sql |
diffstat | 2 files changed, 29 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/geoserver/boot.go Fri Nov 30 15:31:00 2018 +0100 +++ b/pkg/geoserver/boot.go Fri Nov 30 15:56:34 2018 +0100 @@ -29,10 +29,11 @@ ) const ( - workspaceName = "gemma" - datastoreName = "gemma" - databaseScheme = "waterway" - databaseType = "postgis" + workspaceName = "gemma" + datastoreName = "gemma" + databaseScheme = "waterway" + databaseType = "postgis" + primaryKeyMetadataTbl = "waterway.gt_pk_metadata" ) const ( @@ -168,6 +169,7 @@ {"user", config.DBUser()}, {"passwd", config.DBPassword()}, {"dbtype", databaseType}, + {"Primary key metadata table", primaryKeyMetadataTbl}, {"Session startup SQL", startupSQL}, {"Session close-up SQL", closeupSQL}, },
--- a/schema/gemma.sql Fri Nov 30 15:31:00 2018 +0100 +++ b/schema/gemma.sql Fri Nov 30 15:56:34 2018 +0100 @@ -327,6 +327,23 @@ (location_code).hectometre FROM waterway.distance_marks_virtual + -- 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')) + ) + CREATE TABLE sections_stretches ( id varchar PRIMARY KEY, is_section boolean NOT NULL, -- maps 'function' from interface @@ -526,6 +543,12 @@ ORDER BY objnam ; +-- Configure primary keys for geoserver views +INSERT INTO waterway.gt_pk_metadata VALUES ('waterway', + 'distance_marks_geoserver', + 'location_code'); + + -- -- Import queue and respective logging --