From aa6907818bc7232f3b42983b4493e30e2b5aaeb6 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Sun, 5 Oct 2025 20:24:04 +0000 Subject: [PATCH] Prevent ROLES.Participant from changing Allowing the Participant to change means that the ROLES trigger must check ARRIVALS.Cycle against sex and birthdate. And maybe other checks. This is simpler. --- db/schemas/lib/triggers/create/roles.m4 | 8 ++++++-- doc/src/tables/roles.m4 | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/db/schemas/lib/triggers/create/roles.m4 b/db/schemas/lib/triggers/create/roles.m4 index 9f7f783..492a6a8 100644 --- a/db/schemas/lib/triggers/create/roles.m4 +++ b/db/schemas/lib/triggers/create/roles.m4 @@ -44,11 +44,15 @@ CREATE OR REPLACE FUNCTION roles_func () -- This is too much work; easier to require the role be deleted -- and a new one created. cannot_change(`ROLES', `EID') + + -- Allowing the Participant to change means that this trigger must + -- check ARRIVALS.Cycle against sex and birthdate. And maybe + -- other checks. This is simpler. + cannot_change(`ROLES', `Participant') END IF; -- The participant must be under study at the time of the follow. - IF TG_OP = 'INSERT' - OR (NEW.participant <> OLD.participant) THEN + IF TG_OP = 'INSERT' THEN DECLARE a_entrydate biography_data.entrydate%TYPE; a_departdate biography_data.departdate%TYPE; diff --git a/doc/src/tables/roles.m4 b/doc/src/tables/roles.m4 index 86ec712..5f41a20 100644 --- a/doc/src/tables/roles.m4 +++ b/doc/src/tables/roles.m4 @@ -56,7 +56,7 @@ PID (Participant ID) The column is named PID, for Participant ID, because each row represents a participant in the related event. -|ROLES.EID_summary| |notnull| +|ROLES.EID_summary| |cannot_change| |notnull| .. _ROLES.EID: -- 2.34.1