From cf93a2324c1da0b06b3de71a808fc28675684411 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 17 Nov 2021 09:56:48 +0000 Subject: [PATCH] [21.05.x] 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 --- installer/data/mysql/atomicupdate/bug_29495.perl | 10 ++++++++++ installer/data/mysql/kohastructure.sql | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_29495.perl diff --git a/installer/data/mysql/atomicupdate/bug_29495.perl b/installer/data/mysql/atomicupdate/bug_29495.perl new file mode 100644 index 0000000000..1ba2e5ecd3 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_29495.perl @@ -0,0 +1,10 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + if ( foreign_key_exists( 'return_claims', 'issue_id' ) ) { + $dbh->do(q{ + ALTER TABLE return_claims DROP FOREIGN KEY issue_id + }); + } + + NewVersion( $DBversion, 29495, "Issue link is lost in return claims when using 'MarkLostItemsAsReturned'"); +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 0687a6c2fc..38d8544f27 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4364,7 +4364,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.35.1