From 351eb6c26d68342d8dc20fb8f68b7e28ba007820 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 23 Oct 2020 15:46:03 +0100 Subject: [PATCH] Bug 24412: (QA follow-up) Change CASCADE DELETE to SET NULL I don't believe waiting reserves should be removed if a desk is deleted, we should instead simply unset the desk. Signed-off-by: Jonathan Druart --- .../bug_24412_Attach_waiting_reserve_to_desk.perl | 4 ++-- installer/data/mysql/kohastructure.sql | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_24412_Attach_waiting_reserve_to_desk.perl b/installer/data/mysql/atomicupdate/bug_24412_Attach_waiting_reserve_to_desk.perl index 9242ffbd3d..011b734d6a 100644 --- a/installer/data/mysql/atomicupdate/bug_24412_Attach_waiting_reserve_to_desk.perl +++ b/installer/data/mysql/atomicupdate/bug_24412_Attach_waiting_reserve_to_desk.perl @@ -4,7 +4,7 @@ if( CheckVersion( $DBversion ) ) { $dbh->do(q{ ALTER TABLE reserves ADD COLUMN desk_id INT(11) DEFAULT NULL AFTER branchcode, ADD KEY desk_id (`desk_id`), - ADD CONSTRAINT `reserves_ibfk_6` FOREIGN KEY (`desk_id`) REFERENCES `desks` (`desk_id`) ON DELETE CASCADE ON UPDATE CASCADE ; + ADD CONSTRAINT `reserves_ibfk_6` FOREIGN KEY (`desk_id`) REFERENCES `desks` (`desk_id`) ON DELETE SET NULL ON UPDATE CASCADE ; }); $dbh->do(q{ ALTER TABLE old_reserves ADD COLUMN desk_id INT(11) DEFAULT NULL AFTER branchcode, @@ -12,6 +12,6 @@ if( CheckVersion( $DBversion ) ) { }); SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug XXXXX - Attach waiting reserve to desk)\n"; + print "Upgrade to $DBversion done (Bug 24412 - Attach waiting reserve to desk)\n"; } } diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 482f004735..319de0d148 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1793,7 +1793,7 @@ CREATE TABLE `reserves` ( -- information related to holds/reserves in Koha CONSTRAINT `reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `reserves_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `reserves_ibfk_5` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `reserves_ibfk_6` FOREIGN KEY (`desk_id`) REFERENCES `desks` (`desk_id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `reserves_ibfk_6` FOREIGN KEY (`desk_id`) REFERENCES `desks` (`desk_id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; --