From 03fc5fc23aab29de81af33952b4a535eb25c9638 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Wed, 1 Oct 2025 21:27:44 +0000 Subject: [PATCH] The COMM_MEMB_LOG.CommMLID cannot change --- db/schemas/lib/triggers/Makefile | 1 + .../lib/triggers/create/comm_memb_log.m4 | 50 +++++++++++++++++++ db/schemas/lib/triggers/drop/comm_memb_log.m4 | 23 +++++++++ 3 files changed, 74 insertions(+) create mode 100644 db/schemas/lib/triggers/create/comm_memb_log.m4 create mode 100644 db/schemas/lib/triggers/drop/comm_memb_log.m4 diff --git a/db/schemas/lib/triggers/Makefile b/db/schemas/lib/triggers/Makefile index 2112f94..e91259f 100644 --- a/db/schemas/lib/triggers/Makefile +++ b/db/schemas/lib/triggers/Makefile @@ -23,6 +23,7 @@ ORDER := comm_ids \ departtypes \ biography_data \ comm_membs \ + comm_memb_log \ cycle_states \ _error_immutable_view \ follow_observers \ diff --git a/db/schemas/lib/triggers/create/comm_memb_log.m4 b/db/schemas/lib/triggers/create/comm_memb_log.m4 new file mode 100644 index 0000000..078ac3e --- /dev/null +++ b/db/schemas/lib/triggers/create/comm_memb_log.m4 @@ -0,0 +1,50 @@ +dnl Copyright (C) 2015 The Meme Factory, Inc. http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify it +dnl under the terms of the GNU Affero General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Triggers for the comm_memb_log table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`macros.m4')dnl + + +RAISE INFO 'comm_memb_log_func'; +CREATE OR REPLACE FUNCTION comm_memb_log_func () + RETURNS trigger + LANGUAGE plpgsql + sdb_function_set_search_path + AS $$ + BEGIN + -- Function for comm_memb_log update trigger + -- + -- AGPL_notice(` --', `2025', + `The Meme Factory, Inc., www.karlpinc.com') + + -- Allowing the CommMLID to change makes life too complicated. + cannot_change(`COMM_MEMB_LOG', `CommMLID') + + RETURN NULL; + END; +$$; + + +RAISE INFO 'comm_memb_log_trigger'; +CREATE TRIGGER comm_memb_log_trigger + AFTER UPDATE + ON comm_memb_log FOR EACH ROW + EXECUTE PROCEDURE comm_memb_log_func(); diff --git a/db/schemas/lib/triggers/drop/comm_memb_log.m4 b/db/schemas/lib/triggers/drop/comm_memb_log.m4 new file mode 100644 index 0000000..2930e42 --- /dev/null +++ b/db/schemas/lib/triggers/drop/comm_memb_log.m4 @@ -0,0 +1,23 @@ +dnl Copyright (C) 2025 The Meme Factory, Inc. http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Drop triggers for comm_memb_log table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl + +DROP FUNCTION IF EXISTS comm_memb_log_func() CASCADE; -- 2.34.1