Bug 28972: Add missing foreign key constraints to holds queue table
authorKyle M Hall <kyle@bywatersolutions.com>
Wed, 8 Sep 2021 12:02:05 +0000 (08:02 -0400)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 20 Sep 2021 12:04:48 +0000 (14:04 +0200)
The table tmp_holdsqueue is missing a couple key constraints that should
be there, one for biblio and one for borrowers.

Test Plan:
1) "SHOW CREATE TABLE tmp_holdsqueue;" should show no FKs for biblio or borrowers
2) Apply this patch
3) Run updatedatabase.pl
4) "SHOW CREATE TABLE tmp_holdsqueue;" should now show FKs for biblio or borrowers

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
installer/data/mysql/atomicupdate/bug_28972.pl [new file with mode: 0755]
installer/data/mysql/kohastructure.sql

diff --git a/installer/data/mysql/atomicupdate/bug_28972.pl b/installer/data/mysql/atomicupdate/bug_28972.pl
new file mode 100755 (executable)
index 0000000..c475ae5
--- /dev/null
@@ -0,0 +1,15 @@
+use Modern::Perl;
+
+return {
+    bug_number => "28972",
+    description => "Add missing foreign key constraints to holds queue table",
+    up => sub {
+        my ($args) = @_;
+        my ($dbh, $out) = @$args{qw(dbh out)};
+        $dbh->do(q{
+            ALTER TABLE tmp_holdsqueue
+            ADD CONSTRAINT `tmp_holdsqueue_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+            ADD CONSTRAINT `tmp_holdsqueue_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
+        });
+    },
+}
index 02cf864..f9e5c64 100644 (file)
@@ -5103,7 +5103,9 @@ CREATE TABLE `tmp_holdsqueue` (
   `notes` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
   `item_level_request` tinyint(4) NOT NULL DEFAULT 0,
   KEY `tmp_holdsqueue_ibfk_1` (`itemnumber`),
-  CONSTRAINT `tmp_holdsqueue_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
+  CONSTRAINT `tmp_holdsqueue_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `tmp_holdsqueue_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `tmp_holdsqueue_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 /*!40101 SET character_set_client = @saved_cs_client */;