Skip to content

Commit

Permalink
🐛 [BUG] Handle PGRouting fields to reset (refs #4070)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chatewgne committed Jan 16, 2025
1 parent e2359b7 commit 93d0e92
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions geotrek/core/templates/core/sql/post_40_paths.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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();
5 changes: 5 additions & 0 deletions geotrek/core/templates/core/sql/pre_10_cleanup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

0 comments on commit 93d0e92

Please sign in to comment.