Initial definition of the FOLLOWS table
authorKarl O. Pinc kop@karlpinc.com <kop@karlpinc.com>
Fri, 28 Feb 2025 23:52:47 +0000 (23:52 +0000)
committerKarl O. Pinc kop@karlpinc.com <kop@karlpinc.com>
Fri, 28 Feb 2025 23:53:07 +0000 (23:53 +0000)
db/schemas/sokwedb/tables/Makefile
db/schemas/sokwedb/tables/create/follows.m4 [new file with mode: 0644]

index 67dc9da90c8fddd6fc5a658c2b65a1dc50400077..4fdae3a4852b24d38b4cfe2496977428dafbab9f 100644 (file)
@@ -24,7 +24,8 @@ ORDER := biography_data \
          biography_log \
          comm_membs \
          comm_memb_log \
-         sightings
+         sightings \
+         follows
 
 ##
 ## CAUTION: This Makefile is not designed to be run directly.  It is normally
diff --git a/db/schemas/sokwedb/tables/create/follows.m4 b/db/schemas/sokwedb/tables/create/follows.m4
new file mode 100644 (file)
index 0000000..36bb144
--- /dev/null
@@ -0,0 +1,52 @@
+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 <https://www.gnu.org/licenses/>.
+dnl
+dnl Karl O. Pinc <kop@karlpinc.com>
+dnl
+dnl
+dnl m4 includes
+include(`copyright.m4')dnl
+include(`constants.m4')dnl
+include(`tablemacros.m4')dnl
+include(`grants.m4')dnl
+dnl
+
+dnl Macro to generate birthdate constraints to prevent to-early or to-late
+dnl birthdates.
+dnl
+dnl Syntax: birth_constraint(column)
+dnl Variables required:
+dnl   column   The (camel-case) column name
+dnl
+changequote({,})
+define({birth_constraint}, {dnl
+    CONSTRAINT "$1 must not be before sdb_min_birthdate"
+      CHECK ($1 >= 'sdb_min_birthdate')
+    CONSTRAINT "$1 must not be after today's date"
+      CHECK ($1 <= CURRENT_DATE)
+})
+changequote(`,')
+
+
+CREATE TABLE follows (
+   key_column(`FOLLOWS', `FID', INTEGER)
+  ,animid_type_column(`focal', `Focal', `NOT NULL')
+  ,community TEXT NOT NULL
+  ,date DATE NOT NULL
+  ,notes TEXT NOT NULL
+         emptytext_check(`Notes')
+);
+
+grant_priv(`FOLLOWS')