From 563f9faa4f5bb926c99731b8b126ac529bf40958 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 27 Nov 2019 14:49:17 +0100 Subject: [PATCH] Bug 24151: DB changes - pseudonymized_borrower_attributes Add a new DB table pseudonymized_borrower_attributes Sponsored-by: Association KohaLa - https://koha-fr.org/ Signed-off-by: Signed-off-by: Sonia Bouis Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- installer/data/mysql/atomicupdate/bug_24151.perl | 13 +++++++++++++ installer/data/mysql/kohastructure.sql | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/installer/data/mysql/atomicupdate/bug_24151.perl b/installer/data/mysql/atomicupdate/bug_24151.perl index 6dd12888f6..9a97f808b7 100644 --- a/installer/data/mysql/atomicupdate/bug_24151.perl +++ b/installer/data/mysql/atomicupdate/bug_24151.perl @@ -47,6 +47,19 @@ if( CheckVersion( $DBversion ) ) { VALUES ('PseudonymizationTransactionFields','','datetime,transaction_branchcode,transaction_type,itemnumber,itemtype,holdingbranch,location,itemcallnumber,ccode','Transaction fields to copy to the pseudonymized_transactions table','multiple') |); + unless( TableExists( 'pseudonymized_borrower_attributes' ) ) { + $dbh->do(q| + CREATE TABLE pseudonymized_borrower_attributes ( + `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, -- Row id field + `transaction_id` int(11) NOT NULL, + `code` varchar(10) NOT NULL, + `attribute` varchar(255) default NULL, + CONSTRAINT `pseudonymized_borrower_attributes_ibfk_1` FOREIGN KEY (`transaction_id`) REFERENCES `pseudonymized_transactions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `anonymized_borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + |); + } + # Always end with this (adjust the bug info) SetVersion( $DBversion ); print "Upgrade to $DBversion done (Bug 24151 - Add pseudonymized_transactions tables and sysprefs for Pseudonymization)\n"; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 537b41a27d..7f6b3f1f14 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1915,6 +1915,20 @@ CREATE TABLE `pseudonymized_transactions` ( CONSTRAINT `pseudonymized_transactions_borrowers_ibfk_3` FOREIGN KEY (`transaction_branchcode`) REFERENCES `branches` (`branchcode`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +-- +-- Table structure for table borrower_attributes +-- + +DROP TABLE IF EXISTS pseudonymized_borrower_attributes; +CREATE TABLE pseudonymized_borrower_attributes ( -- association table between pseudonymized_transactions and borrower_attributes + `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, -- Row id field + `transaction_id` int(11) NOT NULL, + `code` varchar(10) NOT NULL, -- foreign key from the borrower_attribute_types table, defines which custom field this value was entered for + `attribute` varchar(255) default NULL, -- custom patron field value + CONSTRAINT `pseudonymized_borrower_attributes_ibfk_1` FOREIGN KEY (`transaction_id`) REFERENCES `pseudonymized_transactions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `anonymized_borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + -- -- Table structure for table subscription_frequencies -- -- 2.39.5