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 <andrew@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Martin Renvoize 2021-11-17 09:56:48 +00:00 committed by Fridolin Somers
parent 27587912d7
commit 7beddcb7a9
2 changed files with 15 additions and 1 deletions

View File

@ -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
});
}
},
};

View File

@ -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,