From f4c61260f537fad0aac5179b2a5ae25b56070703 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 --- 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 b84ce3c567..0687a6c2fc 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4209,10 +4209,7 @@ CREATE TABLE `pseudonymized_transactions` ( PRIMARY KEY (`id`), KEY `pseudonymized_transactions_ibfk_1` (`categorycode`), KEY `pseudonymized_transactions_borrowers_ibfk_2` (`branchcode`), - KEY `pseudonymized_transactions_borrowers_ibfk_3` (`transaction_branchcode`), - 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`), - CONSTRAINT `pseudonymized_transactions_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) + KEY `pseudonymized_transactions_borrowers_ibfk_3` (`transaction_branchcode`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- 2.39.5