From 6f663221946a9d9ab5bdba586c2696f3302ebd30 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 30 Mar 2023 10:49:51 +0200 Subject: [PATCH] Bug 22440: Add missing foreign key Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- .../atomicupdate/bug_22440_ill_requests.pl | 19 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 1 + 2 files changed, 20 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_22440_ill_requests.pl diff --git a/installer/data/mysql/atomicupdate/bug_22440_ill_requests.pl b/installer/data/mysql/atomicupdate/bug_22440_ill_requests.pl new file mode 100755 index 0000000000..301508143b --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_22440_ill_requests.pl @@ -0,0 +1,19 @@ +use Modern::Perl; + +return { + bug_number => "22440", + description => "Add new /ill_requests endopoint", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + if ( foreign_key_exists( 'illrequests', 'illrequests_bibfk' ) ) { + $dbh->do(q{ + ALTER TABLE illrequests + ADD FOREIGN KEY illrequests_bibfk (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE; + }); + + say $out "Added foreign key constraint 'illrequests.illrequests_bibfk'"; + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 50796112dc..4b57ae21ba 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3282,6 +3282,7 @@ CREATE TABLE `illrequests` ( KEY `illrequests_bnfk` (`borrowernumber`), KEY `illrequests_bcfk_2` (`branchcode`), KEY `illrequests_safk` (`status_alias`), + CONSTRAINT `illrequests_bibfk` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `illrequests_bcfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `illrequests_bnfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `illrequests_safk` FOREIGN KEY (`status_alias`) REFERENCES `authorised_values` (`authorised_value`) ON DELETE SET NULL ON UPDATE CASCADE -- 2.39.5