From 9af76f88bfb4fc54cd49f2cdd0221b1d8b12cbb0 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 --- installer/data/mysql/atomicupdate/bug_29495.pl | 15 +++++++++++++++ installer/data/mysql/kohastructure.sql | 1 - 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 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 100644 index 0000000000..b492b8597f --- /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 contraint 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 d5768b9e9c..4cbfaa7cd4 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4385,7 +4385,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.20.1