From 08aca588d0eed7d900fa299493c57dee36e83fcb Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Fri, 13 Sep 2024 18:00:50 +0200 Subject: [PATCH] Ignore last_modified columns for all tables in change log trigger --- rest-api/db/migrations/20240911070907_change_log.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rest-api/db/migrations/20240911070907_change_log.sql b/rest-api/db/migrations/20240911070907_change_log.sql index d4fe544..30e90ea 100644 --- a/rest-api/db/migrations/20240911070907_change_log.sql +++ b/rest-api/db/migrations/20240911070907_change_log.sql @@ -18,10 +18,10 @@ CREATE FUNCTION internal.track_changes () DECLARE _website_id UUID; BEGIN + IF (to_jsonb (OLD.*) - 'last_modified_at') = (to_jsonb (NEW.*) - 'last_modified_at') OR (to_jsonb (OLD.*) - 'last_modified_by') = (to_jsonb (NEW.*) - 'last_modified_by') THEN + RETURN NEW; + END IF; IF TG_TABLE_NAME = 'website' THEN - IF (to_jsonb (OLD.*) - 'last_modified_at') = (to_jsonb (NEW.*) - 'last_modified_at') OR (to_jsonb (OLD.*) - 'last_modified_by') = (to_jsonb (NEW.*) - 'last_modified_by') THEN - RETURN NEW; - END IF; _website_id := NEW.id; ELSE _website_id := COALESCE(NEW.website_id, OLD.website_id);