From 905bf40e1699971c0bf3f45f15482586e6192a66 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Sun, 1 Mar 2026 01:04:53 +0000 Subject: [PATCH] Make ESTRUS_STATES table and indexes --- db/schemas/sokwedb/indexes/Makefile | 2 +- .../sokwedb/indexes/create/estrus_states.m4 | 29 ++++++++++++++ .../sokwedb/indexes/drop/estrus_states.m4 | 27 +++++++++++++ db/schemas/sokwedb/tables/Makefile | 1 + .../sokwedb/tables/create/estrus_states.m4 | 40 +++++++++++++++++++ 5 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 db/schemas/sokwedb/indexes/create/estrus_states.m4 create mode 100644 db/schemas/sokwedb/indexes/drop/estrus_states.m4 create mode 100644 db/schemas/sokwedb/tables/create/estrus_states.m4 diff --git a/db/schemas/sokwedb/indexes/Makefile b/db/schemas/sokwedb/indexes/Makefile index 29e56b1..5e69d60 100644 --- a/db/schemas/sokwedb/indexes/Makefile +++ b/db/schemas/sokwedb/indexes/Makefile @@ -21,7 +21,7 @@ # This is not really important but is needed for other types of db objects. ORDER := biography_data biography_log comm_membs comm_memb_log \ follows follow_observers follow_studies events roles arrivals \ - estrus_sources + estrus_sources estrus_states ## ## CAUTION: This Makefile is not designed to be run directly. It is normally diff --git a/db/schemas/sokwedb/indexes/create/estrus_states.m4 b/db/schemas/sokwedb/indexes/create/estrus_states.m4 new file mode 100644 index 0000000..ee643df --- /dev/null +++ b/db/schemas/sokwedb/indexes/create/estrus_states.m4 @@ -0,0 +1,29 @@ +dnl Copyright (C) 2026 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(`indexmacros.m4')dnl + +CREATE INDEX IF NOT EXISTS estrus_states_date ON estrus_states + (date); +CREATE INDEX IF NOT EXISTS estrus_states_animid ON estrus_states + (animid); + + diff --git a/db/schemas/sokwedb/indexes/drop/estrus_states.m4 b/db/schemas/sokwedb/indexes/drop/estrus_states.m4 new file mode 100644 index 0000000..9704825 --- /dev/null +++ b/db/schemas/sokwedb/indexes/drop/estrus_states.m4 @@ -0,0 +1,27 @@ +dnl Copyright (C) 2026 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(`indexmacros.m4')dnl + +DROP INDEX IF EXISTS estrus_states_date; +DROP INDEX IF EXISTS estrus_states_animid; + + diff --git a/db/schemas/sokwedb/tables/Makefile b/db/schemas/sokwedb/tables/Makefile index 52fe9bb..5eaf443 100644 --- a/db/schemas/sokwedb/tables/Makefile +++ b/db/schemas/sokwedb/tables/Makefile @@ -23,6 +23,7 @@ ORDER := biography_data \ biography_log \ estrus_sources \ + estrus_states \ comm_membs \ comm_memb_log \ sightings \ diff --git a/db/schemas/sokwedb/tables/create/estrus_states.m4 b/db/schemas/sokwedb/tables/create/estrus_states.m4 new file mode 100644 index 0000000..6802310 --- /dev/null +++ b/db/schemas/sokwedb/tables/create/estrus_states.m4 @@ -0,0 +1,40 @@ +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 + +CREATE TABLE estrus_states ( + key_column(`ESTRUS_STATES', `ID', `INTEGER') + ,date DATE NOT NULL + ,animid_type_column(`animid', `AnimID', `NOT NULL') + ,estrusmin TEXT NOT NULL + REFERENCES cycle_states + ,estrusminsource TEXT NOT NULL + REFERENCES sighting_records + ,estrusmax TEXT NOT NULL + REFERENCES cycle_states + ,estrusmaxsource TEXT NOT NULL + REFERENCES sighting_records +); + +grant_priv(`ESTRUS_STATES') -- 2.34.1