From 82a4d11b148effa5e31522a11e49cbbf0f5fee0e Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Sun, 1 Mar 2026 00:04:02 +0000 Subject: [PATCH] Create SIGHTING_RECORDS table and indexes --- db/schemas/codes/indexes/Makefile | 3 +- .../codes/indexes/create/sighting_records.m4 | 30 ++++++++++++++++ .../codes/indexes/drop/sighting_records.m4 | 25 +++++++++++++ db/schemas/codes/tables/Makefile | 1 + .../codes/tables/create/sighting_records.m4 | 35 +++++++++++++++++++ 5 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 db/schemas/codes/indexes/create/sighting_records.m4 create mode 100644 db/schemas/codes/indexes/drop/sighting_records.m4 create mode 100644 db/schemas/codes/tables/create/sighting_records.m4 diff --git a/db/schemas/codes/indexes/Makefile b/db/schemas/codes/indexes/Makefile index f6f9ba2..06d208b 100644 --- a/db/schemas/codes/indexes/Makefile +++ b/db/schemas/codes/indexes/Makefile @@ -26,7 +26,8 @@ ORDER := arrival_sources \ dad_statuses \ obs_periods \ people \ - role_codes + role_codes \ + sighting_records ## ## CAUTION: This Makefile is not designed to be run directly. It is normally diff --git a/db/schemas/codes/indexes/create/sighting_records.m4 b/db/schemas/codes/indexes/create/sighting_records.m4 new file mode 100644 index 0000000..5b6b05d --- /dev/null +++ b/db/schemas/codes/indexes/create/sighting_records.m4 @@ -0,0 +1,30 @@ +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 UNIQUE INDEX IF NOT EXISTS sighting_records_code_uniquenocase + ON sighting_records + (sdb_case_equivalence(code)); + +CREATE UNIQUE INDEX IF NOT EXISTS sighting_records_priority + ON sighting_records + (priority); diff --git a/db/schemas/codes/indexes/drop/sighting_records.m4 b/db/schemas/codes/indexes/drop/sighting_records.m4 new file mode 100644 index 0000000..29c6c2b --- /dev/null +++ b/db/schemas/codes/indexes/drop/sighting_records.m4 @@ -0,0 +1,25 @@ +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(`macros.m4')dnl + +DROP INDEX IF EXISTS comm_ids_code_uniquenocase; +DROP INDEX IF EXISTS comm_ids_priority; diff --git a/db/schemas/codes/tables/Makefile b/db/schemas/codes/tables/Makefile index d150ab0..6a4c665 100644 --- a/db/schemas/codes/tables/Makefile +++ b/db/schemas/codes/tables/Makefile @@ -31,6 +31,7 @@ ORDER := arrival_sources \ people \ obs_periods \ role_codes \ + sighting_records \ species \ studies diff --git a/db/schemas/codes/tables/create/sighting_records.m4 b/db/schemas/codes/tables/create/sighting_records.m4 new file mode 100644 index 0000000..140c1d8 --- /dev/null +++ b/db/schemas/codes/tables/create/sighting_records.m4 @@ -0,0 +1,35 @@ +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(`tablemacros.m4')dnl +include(`grants.m4')dnl +dnl + +CREATE TABLE sighting_records ( + code TEXT PRIMARY KEY NOT NULL + emptytext_check(`Code') + nospaces_check(`Code') + ,priority INTEGER NOT NULL + ,description TEXT NOT NULL + notonlyspaces_check(`Description') +); + +grant_priv(`SIGHTING_RECORDS') -- 2.34.1