Line 0
Link Here
|
|
|
1 |
$DBversion = 'XXX'; # will be replaced by the RM |
2 |
if( CheckVersion( $DBversion ) ) { |
3 |
unless( TableExists( 'pseudonymized_transactions' ) ) { |
4 |
$dbh->do(q| |
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, |
9 |
`title` LONGTEXT, |
10 |
`city` LONGTEXT, |
11 |
`state` MEDIUMTEXT default NULL, |
12 |
`zipcode` varchar(25) default NULL, |
13 |
`country` MEDIUMTEXT, |
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, |
29 |
PRIMARY KEY (`id`), |
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; |
34 |
|); |
35 |
} |
36 |
|
37 |
$dbh->do(q| |
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') |
40 |
|); |
41 |
$dbh->do(q| |
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') |
44 |
|); |
45 |
$dbh->do(q| |
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') |
48 |
|); |
49 |
|
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"; |
53 |
} |