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 +);