View | Details | Raw Unified | Return to bug 24151
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_XXXXX.perl (+46 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    unless( TableExists( 'anonymized_borrowers' ) ) {
4
        $dbh->do(q|
5
            CREATE TABLE `anonymized_borrowers` (
6
              `hashed_borrowernumber` VARCHAR(60) NOT NULL,
7
              `has_cardnumber` TINYINT(1) NOT NULL DEFAULT 0,
8
              `title` LONGTEXT,
9
              `city` LONGTEXT,
10
              `state` MEDIUMTEXT default NULL,
11
              `zipcode` varchar(25) default NULL,
12
              `country` MEDIUMTEXT,
13
              `branchcode` varchar(10) NOT NULL default '',
14
              `categorycode` varchar(10) NOT NULL default '',
15
              `dateenrolled` date default NULL,
16
              `sex` varchar(1) default NULL,
17
              `sort1` varchar(80) default NULL,
18
              `sort2` varchar(80) default NULL,
19
              PRIMARY KEY `hashed_borrowernumber` (`hashed_borrowernumber`),
20
              CONSTRAINT `anon_borrowers_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`),
21
              CONSTRAINT `anon_borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
22
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
23
        |);
24
    }
25
    unless( TableExists( 'anonymized_transactions' ) ) {
26
        $dbh->do(q|
27
            CREATE TABLE `anonymized_transactions` (
28
              `hashed_borrowernumber` VARCHAR(60) NOT NULL,
29
              `datetime` datetime default NULL,
30
              `branchcode` varchar(10) default NULL,
31
              `transaction_type` varchar(16) default NULL,
32
              `itemnumber` int(11) default NULL,
33
              `itemtype` varchar(10) default NULL,
34
              `holdingbranch` varchar(10) default null,
35
              `location` varchar(80) default NULL,
36
              `itemcallnumber` varchar(255) default NULL,
37
              `ccode` varchar(80) default NULL,
38
              CONSTRAINT `anonymized_transactions_ibfk_1` FOREIGN KEY (`hashed_borrowernumber`) REFERENCES `anonymized_borrowers` (`hashed_borrowernumber`)
39
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
40
        |);
41
    }
42
43
    # Always end with this (adjust the bug info)
44
    SetVersion( $DBversion );
45
    print "Upgrade to $DBversion done (Bug XXXXX - description)\n";
46
}
(-)a/installer/data/mysql/kohastructure.sql (-1 / +43 lines)
Lines 1597-1602 CREATE TABLE `borrowers` ( -- this table includes information about your patrons Link Here
1597
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1597
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1598
1598
1599
--
1599
--
1600
-- Table structure for table `anonymized_borrowers`
1601
--
1602
1603
DROP TABLE IF EXISTS `anonymized_borrowers`;
1604
CREATE TABLE `anonymized_borrowers` (
1605
  `hashed_borrowernumber` VARCHAR(60) NOT NULL,
1606
  `has_cardnumber` TINYINT(1) NOT NULL DEFAULT 0, -- if the patron has a cardnumber (boolean field)
1607
  `title` LONGTEXT, -- patron/borrower's title, for example: Mr. or Mrs.
1608
  `city` LONGTEXT, -- the city or town for your patron/borrower's primary address
1609
  `state` MEDIUMTEXT default NULL, -- the state or province for your patron/borrower's primary address
1610
  `zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's primary address
1611
  `country` MEDIUMTEXT, -- the country for your patron/borrower's primary address
1612
  `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, includes the code of the patron/borrower's home branch
1613
  `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table, includes the code of the patron category
1614
  `dateenrolled` date default NULL, -- date the patron was added to Koha (YYYY-MM-DD)
1615
  `sex` varchar(1) default NULL, -- patron/borrower's gender
1616
  `sort1` varchar(80) default NULL, -- a field that can be used for any information unique to the library
1617
  `sort2` varchar(80) default NULL, -- a field that can be used for any information unique to the library
1618
  PRIMARY KEY `hashed_borrowernumber` (`hashed_borrowernumber`),
1619
  CONSTRAINT `anon_borrowers_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`),
1620
  CONSTRAINT `anon_borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
1621
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1622
1623
--
1624
-- Table structure for table `anonymized_transactions`
1625
--
1626
1627
DROP TABLE IF EXISTS `anonymized_transactions`;
1628
CREATE TABLE `anonymized_transactions` (
1629
  `hashed_borrowernumber` VARCHAR(60) NOT NULL,
1630
  `datetime` datetime default NULL, -- date and time of the transaction
1631
  `branchcode` varchar(10) default NULL, -- foreign key, branch where the transaction occurred
1632
  `transaction_type` varchar(16) default NULL, -- transaction type (localuse, issue, return, renew, writeoff, payment)
1633
  `itemnumber` int(11) default NULL, -- foreign key from the items table, links transaction to a specific item
1634
  `itemtype` varchar(10) default NULL, -- foreign key from the itemtypes table, links transaction to a specific item type
1635
  `holdingbranch` varchar(10) default null,
1636
  `location` varchar(80) default NULL, -- authorized value for the shelving location for this item (MARC21 952$c)
1637
  `itemcallnumber` varchar(255) default NULL, -- item's itemcallnumber
1638
  `ccode` varchar(80) default NULL, -- foreign key from the items table, links transaction to a specific collection code
1639
  CONSTRAINT `anonymized_transactions_ibfk_1` FOREIGN KEY (`hashed_borrowernumber`) REFERENCES `anonymized_borrowers` (`hashed_borrowernumber`)
1640
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1641
1642
--
1600
-- Table structure for table `borrower_attributes`
1643
-- Table structure for table `borrower_attributes`
1601
--
1644
--
1602
1645
1603
- 

Return to bug 24151