From 536c3ca639791e3f2f0d09cec72133a632e718fa Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Sun, 21 Sep 2025 21:43:35 +0000 Subject: [PATCH] Add CYCLE_STATES table to db --- db/schemas/codes/tables/Makefile | 1 + .../codes/tables/create/cycle_states.m4 | 29 +++++++++++ db/schemas/lib/triggers/Makefile | 1 + .../lib/triggers/create/cycle_states.m4 | 50 +++++++++++++++++++ db/schemas/lib/triggers/drop/cycle_states.m4 | 23 +++++++++ 5 files changed, 104 insertions(+) create mode 100644 db/schemas/codes/tables/create/cycle_states.m4 create mode 100644 db/schemas/lib/triggers/create/cycle_states.m4 create mode 100644 db/schemas/lib/triggers/drop/cycle_states.m4 diff --git a/db/schemas/codes/tables/Makefile b/db/schemas/codes/tables/Makefile index 2523c44..6d02279 100644 --- a/db/schemas/codes/tables/Makefile +++ b/db/schemas/codes/tables/Makefile @@ -23,6 +23,7 @@ ORDER := certainties \ comm_ids \ comm_membs_sources \ + cycle_states \ departtypes \ entrytypes \ people \ diff --git a/db/schemas/codes/tables/create/cycle_states.m4 b/db/schemas/codes/tables/create/cycle_states.m4 new file mode 100644 index 0000000..192fd8a --- /dev/null +++ b/db/schemas/codes/tables/create/cycle_states.m4 @@ -0,0 +1,29 @@ +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 +dnl by 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 Karl O. Pinc +dnl +dnl +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`tablemacros.m4')dnl +include(`grants.m4')dnl +dnl + +support_table(`CYCLE_STATES', `Code', `TEXT', ` + emptytext_check(`Code') + uppercase_check(`Code')' +) diff --git a/db/schemas/lib/triggers/Makefile b/db/schemas/lib/triggers/Makefile index e1361f4..118b352 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 \ + cycle_states \ _error_immutable_view \ follow_observers \ biography diff --git a/db/schemas/lib/triggers/create/cycle_states.m4 b/db/schemas/lib/triggers/create/cycle_states.m4 new file mode 100644 index 0000000..6beeb0e --- /dev/null +++ b/db/schemas/lib/triggers/create/cycle_states.m4 @@ -0,0 +1,50 @@ +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 Triggers for cycle_states table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`macros.m4')dnl + +RAISE INFO 'cycle_states_func'; +CREATE OR REPLACE FUNCTION cycle_states_func () + RETURNS trigger + LANGUAGE plpgsql + sdb_function_set_search_path + AS $$ + BEGIN + -- Function for cycle_states insert and update triggers + -- + -- AGPL_notice(` --', `2025', + `The Meme Factory, Inc., www.karlpinc.com') + + IF TG_OP = 'UPDATE' THEN + restrict_special_row(`CYCLE_STATES', `Code', sdb_male_swelling) + restrict_special_row(`CYCLE_STATES', `Code', sdb_adolescent_swelling) + END IF; + + RETURN NULL; + END; +$$; + +RAISE INFO 'cycle_states_trigger'; +CREATE TRIGGER cycle_states_trigger + AFTER INSERT OR UPDATE + ON cycle_states FOR EACH ROW + EXECUTE PROCEDURE cycle_states_func(); diff --git a/db/schemas/lib/triggers/drop/cycle_states.m4 b/db/schemas/lib/triggers/drop/cycle_states.m4 new file mode 100644 index 0000000..ced4326 --- /dev/null +++ b/db/schemas/lib/triggers/drop/cycle_states.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 the cycle_states table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl + +DROP FUNCTION IF EXISTS cycle_states_func() CASCADE; -- 2.34.1