From aa2ec37ce18cb0e965707abb9fd18393d13e4910 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 17 Nov 2021 12:25:35 +0100 Subject: [PATCH] Bug 29341: Remove foreign keys on pseudonymized_transactions Behave like the statistics table and don't remove the code even if the branch or patron's category is removed. Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit f4c61260f537fad0aac5179b2a5ae25b56070703) Signed-off-by: Fridolin Somers --- installer/data/mysql/atomicupdate/bug_29341.pl | 17 +++++++++++++++++ installer/data/mysql/kohastructure.sql | 5 +---- 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_29341.pl diff --git a/installer/data/mysql/atomicupdate/bug_29341.pl b/installer/data/mysql/atomicupdate/bug_29341.pl new file mode 100755 index 0000000000..d9abc04b9c --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_29341.pl @@ -0,0 +1,17 @@ +use Modern::Perl; + +return { + bug_number => "29341", + description => "Remove foreign keys on pseudonymized_transactions", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + for my $fk ( qw( pseudonymized_transactions_borrowers_ibfk_2 pseudonymized_transactions_borrowers_ibfk_3 pseudonymized_transactions_ibfk_1 ) ) { + if ( foreign_key_exists( 'pseudonymized_transactions', $fk ) ) { + $dbh->do(qq{ + ALTER TABLE pseudonymized_transactions DROP FOREIGN KEY $fk + }); + } + } + }, +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index c6535134a3..13a43b53c4 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1964,10 +1964,7 @@ CREATE TABLE `pseudonymized_transactions` ( `location` varchar(80) default NULL, `itemcallnumber` varchar(255) default NULL, `ccode` varchar(80) default NULL, - PRIMARY KEY (`id`), - CONSTRAINT `pseudonymized_transactions_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`), - CONSTRAINT `pseudonymized_transactions_borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`), - CONSTRAINT `pseudonymized_transactions_borrowers_ibfk_3` FOREIGN KEY (`transaction_branchcode`) REFERENCES `branches` (`branchcode`) + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- 2.39.5