From 0a534f736aa9e87a9faecd1e0eba3e5df0e45630 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Dec 2023 10:35:17 +0100 Subject: [PATCH] Bug 35610: Add FK on old_reserves.branchcode Signed-off-by: Kyle M Hall Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Katrin Fischer (cherry picked from commit 943838ed9950f95325558ae71590559bcb349352) Signed-off-by: Fridolin Somers --- installer/data/mysql/atomicupdate/bug_35610.pl | 18 ++++++++++++++++++ installer/data/mysql/kohastructure.sql | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_35610.pl diff --git a/installer/data/mysql/atomicupdate/bug_35610.pl b/installer/data/mysql/atomicupdate/bug_35610.pl new file mode 100755 index 0000000000..e9e2c10725 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_35610.pl @@ -0,0 +1,18 @@ +use Modern::Perl; + +return { + bug_number => "35610", + description => "Add FK on old_reserves.branchcode", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + unless ( foreign_key_exists('old_reserves', 'old_reserves_ibfk_branchcode') ) { + $dbh->do(q{ + ALTER TABLE old_reserves + ADD CONSTRAINT `old_reserves_ibfk_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE; + }); + say $out "Added foreign key on 'old_reserves.branchcode'" + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index ea540c0819..3828776962 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4916,7 +4916,8 @@ CREATE TABLE `old_reserves` ( CONSTRAINT `old_reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE SET NULL, CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL, CONSTRAINT `old_reserves_ibfk_4` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE SET NULL ON UPDATE SET NULL, - CONSTRAINT `old_reserves_ibfk_ig` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE SET NULL ON UPDATE SET NULL + CONSTRAINT `old_reserves_ibfk_ig` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE SET NULL ON UPDATE SET NULL, + CONSTRAINT `old_reserves_ibfk_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- 2.39.5