1 $DBversion = 'XXX'; # will be replaced by the RM
2 if( CheckVersion( $DBversion ) ) {
3 unless( TableExists( 'pseudonymized_transactions' ) ) {
5 CREATE TABLE `pseudonymized_transactions` (
6 `id` INT(11) NOT NULL AUTO_INCREMENT,
7 `hashed_borrowernumber` VARCHAR(60) NOT NULL,
8 `has_cardnumber` TINYINT(1) NOT NULL DEFAULT 0,
11 `state` MEDIUMTEXT default NULL,
12 `zipcode` varchar(25) default NULL,
14 `branchcode` varchar(10) NOT NULL default '',
15 `categorycode` varchar(10) NOT NULL default '',
16 `dateenrolled` date default NULL,
17 `sex` varchar(1) default NULL,
18 `sort1` varchar(80) default NULL,
19 `sort2` varchar(80) default NULL,
20 `datetime` datetime default NULL,
21 `transaction_branchcode` varchar(10) default NULL,
22 `transaction_type` varchar(16) default NULL,
23 `itemnumber` int(11) default NULL,
24 `itemtype` varchar(10) default NULL,
25 `holdingbranch` varchar(10) default null,
26 `location` varchar(80) default NULL,
27 `itemcallnumber` varchar(255) default NULL,
28 `ccode` varchar(80) default NULL,
30 CONSTRAINT `pseudonymized_transactions_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`),
31 CONSTRAINT `pseudonymized_transactions_borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`),
32 CONSTRAINT `pseudonymized_transactions_borrowers_ibfk_3` FOREIGN KEY (`transaction_branchcode`) REFERENCES `branches` (`branchcode`)
33 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
38 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
39 VALUES ('Pseudonymization','0',NULL,'If enabled patrons and transactions will be copied in a separate table for statistics purpose','YesNo')
42 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
43 VALUES ('PseudonymizationPatronFields','','title,city,state,zipcode,country,branchcode,categorycode,dateenrolled,sex,sort1,sort2','Patron fields to copy to the pseudonymized_transactions table','multiple')
46 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
47 VALUES ('PseudonymizationTransactionFields','','datetime,transaction_branchcode,transaction_type,itemnumber,itemtype,holdingbranch,location,itemcallnumber,ccode','Transaction fields to copy to the pseudonymized_transactions table','multiple')
50 # Always end with this (adjust the bug info)
51 SetVersion( $DBversion );
52 print "Upgrade to $DBversion done (Bug 24151 - Add pseudonymized_transactions tables and sysprefs for Pseudonymization)\n";