From 7170fe2cc5f30e055ffa3ab33648e977ffd3a25c Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 8 Sep 2021 08:02:05 -0400 Subject: [PATCH] Bug 28972: Add missing foreign key constraints to holds queue table MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Joonas Kylmälä Signed-off-by: Jonathan Druart --- installer/data/mysql/atomicupdate/bug_28972.pl | 15 +++++++++++++++ installer/data/mysql/kohastructure.sql | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_28972.pl diff --git a/installer/data/mysql/atomicupdate/bug_28972.pl b/installer/data/mysql/atomicupdate/bug_28972.pl new file mode 100755 index 0000000000..c475ae5fe5 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_28972.pl @@ -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 + }); + }, +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 02cf864ddd..f9e5c6453e 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -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 */; -- 2.39.5