From 49e6324d6807a8cde8517ace37cf51e2223d0fd6 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Thu, 2 Oct 2025 23:29:58 +0000 Subject: [PATCH] Make OBS_PERIODS.Period unique when ignoring case --- db/schemas/codes/indexes/Makefile | 3 ++- .../codes/indexes/create/obs_periods.m4 | 27 +++++++++++++++++++ db/schemas/codes/indexes/drop/obs_periods.m4 | 24 +++++++++++++++++ db/schemas/codes/tables/create/obs_periods.m4 | 3 +-- doc/src/code_tables.m4 | 2 +- 5 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 db/schemas/codes/indexes/create/obs_periods.m4 create mode 100644 db/schemas/codes/indexes/drop/obs_periods.m4 diff --git a/db/schemas/codes/indexes/Makefile b/db/schemas/codes/indexes/Makefile index be90ab8..494461a 100644 --- a/db/schemas/codes/indexes/Makefile +++ b/db/schemas/codes/indexes/Makefile @@ -21,7 +21,8 @@ # This is not really important but is needed for other types of db objects. ORDER := comm_ids \ comm_membs_sources \ - cycle_states + cycle_states \ + obs_periods ## ## CAUTION: This Makefile is not designed to be run directly. It is normally diff --git a/db/schemas/codes/indexes/create/obs_periods.m4 b/db/schemas/codes/indexes/create/obs_periods.m4 new file mode 100644 index 0000000..bdbfb6d --- /dev/null +++ b/db/schemas/codes/indexes/create/obs_periods.m4 @@ -0,0 +1,27 @@ +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(`indexmacros.m4')dnl + +CREATE UNIQUE INDEX IF NOT EXISTS obs_periods_period_uniquenocase + ON obs_periods + (sdb_case_equivalence(period)); + diff --git a/db/schemas/codes/indexes/drop/obs_periods.m4 b/db/schemas/codes/indexes/drop/obs_periods.m4 new file mode 100644 index 0000000..a972a3d --- /dev/null +++ b/db/schemas/codes/indexes/drop/obs_periods.m4 @@ -0,0 +1,24 @@ +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(`macros.m4')dnl + +DROP INDEX IF EXISTS obs_periods_period_uniquenocase; diff --git a/db/schemas/codes/tables/create/obs_periods.m4 b/db/schemas/codes/tables/create/obs_periods.m4 index 088d12e..1d473d8 100644 --- a/db/schemas/codes/tables/create/obs_periods.m4 +++ b/db/schemas/codes/tables/create/obs_periods.m4 @@ -24,6 +24,5 @@ include(`grants.m4')dnl dnl support_table(`OBS_PERIODS', `Period', `TEXT', ` - emptytext_check(`Period') - uppercase_check(`Period')' + emptytext_check(`Period')' ) diff --git a/doc/src/code_tables.m4 b/doc/src/code_tables.m4 index c2b48be..c44894d 100644 --- a/doc/src/code_tables.m4 +++ b/doc/src/code_tables.m4 @@ -393,7 +393,7 @@ Period A code identifying a part the day during which follow observations are, or have been, scheduled. -|OBS_PERIODS.Period_summary| |keycol| |uppercase| +|OBS_PERIODS.Period_summary| |caseuniquekeycol| |uppercase| .. _OBS_PERIODS.Description: -- 2.34.1