From 93d0e92c8a522022e64496148e7759b4ebdd64ac Mon Sep 17 00:00:00 2001 From: Chatewgne Date: Tue, 14 Jan 2025 12:36:23 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20[BUG]=20Handle=20PGRouting=20fie?= =?UTF-8?q?lds=20to=20reset=20(refs=20#4070)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- geotrek/core/templates/core/sql/post_40_paths.sql | 7 ++++--- geotrek/core/templates/core/sql/pre_10_cleanup.sql | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/geotrek/core/templates/core/sql/post_40_paths.sql b/geotrek/core/templates/core/sql/post_40_paths.sql index 643a79ab34..e91dcb1b04 100644 --- a/geotrek/core/templates/core/sql/post_40_paths.sql +++ b/geotrek/core/templates/core/sql/post_40_paths.sql @@ -167,11 +167,12 @@ FOR EACH ROW EXECUTE PROCEDURE path_latest_updated_d(); CREATE FUNCTION {{ schema_geotrek }}.set_pgrouting_values_to_null() RETURNS trigger SECURITY DEFINER AS $$ DECLARE BEGIN - UPDATE core_path SET source = NULL, target = NULL WHERE id = NEW.id; - RETURN NULL; + NEW.source = NULL; + NEW.target = NULL; + RETURN NEW; END; $$ LANGUAGE plpgsql; CREATE TRIGGER core_path_pgrouting_values_null_tgr -AFTER UPDATE OF geom ON core_path +BEFORE UPDATE OF geom ON core_path FOR EACH ROW EXECUTE PROCEDURE set_pgrouting_values_to_null(); diff --git a/geotrek/core/templates/core/sql/pre_10_cleanup.sql b/geotrek/core/templates/core/sql/pre_10_cleanup.sql index e3956328ec..b6bfb9ae0c 100644 --- a/geotrek/core/templates/core/sql/pre_10_cleanup.sql +++ b/geotrek/core/templates/core/sql/pre_10_cleanup.sql @@ -70,3 +70,8 @@ DROP FUNCTION IF EXISTS ft_merge_path(integer,integer) CASCADE; -- 80 DROP FUNCTION IF EXISTS path_deletion() CASCADE; + +CREATE TABLE IF NOT EXISTS pgrouting_paths_to_set_to_null( + id SERIAL PRIMARY KEY, + path_id INTEGER UNIQUE +);