From 7beddcb7a9347e280dee0a2a43bcad5a5405e9bc Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 17 Nov 2021 09:56:48 +0000 Subject: [PATCH] Bug 29495: Drop issue_id constraint from return_claims This patch removes the issue_id constraint from return_claims. Due to the nature of our dual table approach to checkouts/old_checkouts we can't safely hae this constraint and not lose data. Prior to this commit, when an item is checked in we move the checkout from checkouts to old_checkouts.. this therefore triggers the delete of the issue_id from the return_claims table as described by the foreign key constraint. Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Tomas Cohen Arazi Signed-off-by: Fridolin Somers --- installer/data/mysql/atomicupdate/bug_29495.pl | 15 +++++++++++++++ installer/data/mysql/kohastructure.sql | 1 - 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_29495.pl diff --git a/installer/data/mysql/atomicupdate/bug_29495.pl b/installer/data/mysql/atomicupdate/bug_29495.pl new file mode 100755 index 0000000000..8f84f302fb --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_29495.pl @@ -0,0 +1,15 @@ +use Modern::Perl; + +return { + bug_number => "29495", + description => "Drop issue_id constraint from return_claims table", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + if ( foreign_key_exists( 'return_claims', 'issue_id' ) ) { + $dbh->do(q{ + ALTER TABLE return_claims DROP FOREIGN KEY issue_id + }); + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index a309cea736..046372cdd8 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4388,7 +4388,6 @@ CREATE TABLE `return_claims` ( KEY `rc_created_by_ibfk` (`created_by`), KEY `rc_updated_by_ibfk` (`updated_by`), KEY `rc_resolved_by_ibfk` (`resolved_by`), - CONSTRAINT `issue_id` FOREIGN KEY (`issue_id`) REFERENCES `issues` (`issue_id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `rc_borrowers_ibfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `rc_created_by_ibfk` FOREIGN KEY (`created_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `rc_items_ibfk` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE, -- 2.39.5