Bug 14570: Make it possible to add multiple guarantors to a record
[srvgit] / installer / data / mysql / kohastructure.sql
index bd1c803..d28822c 100644 (file)
@@ -132,6 +132,10 @@ CREATE TABLE `biblio` ( -- table that stores bibliographic information
   `frameworkcode` varchar(4) NOT NULL default '', -- foreign key from the biblio_framework table to identify which framework was used in cataloging this record
   `author` LONGTEXT, -- statement of responsibility from MARC record (100$a in MARC21)
   `title` LONGTEXT, -- title (without the subtitle) from the MARC record (245$a in MARC21)
+  `medium` LONGTEXT, -- medium from the MARC record (245$h in MARC21)
+  `subtitle` LONGTEXT, -- remainder of the title from the MARC record (245$b in MARC21)
+  `part_number` LONGTEXT, -- part number from the MARC record (245$n in MARC21)
+  `part_name` LONGTEXT, -- part name from the MARC record (245$p in MARC21)
   `unititle` LONGTEXT, -- uniform title (without the subtitle) from the MARC record (240$a in MARC21)
   `notes` LONGTEXT, -- values from the general notes field in the MARC record (500$a in MARC21) split by bar (|)
   `serial` tinyint(1) default NULL, -- Boolean indicating whether biblio is for a serial
@@ -355,34 +359,6 @@ CREATE TABLE collections_tracking (
 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 --
--- Table structure for table `default_branch_circ_rules`
---
-
-DROP TABLE IF EXISTS `default_branch_circ_rules`;
-CREATE TABLE `default_branch_circ_rules` (
-  `branchcode` VARCHAR(10) NOT NULL,
-  `holdallowed` tinyint(1) default NULL,
-  hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode
-  `returnbranch` varchar(15) default NULL,
-  PRIMARY KEY (`branchcode`),
-  CONSTRAINT `default_branch_circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
-    ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Table structure for table `default_circ_rules`
---
-
-DROP TABLE IF EXISTS `default_circ_rules`;
-CREATE TABLE `default_circ_rules` (
-    `singleton` enum('singleton') NOT NULL default 'singleton',
-    `holdallowed` int(1) default NULL,
-    hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode
-    `returnbranch` varchar(15) default NULL,
-    PRIMARY KEY (`singleton`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
 -- Table structure for table `cities`
 --
 
@@ -469,6 +445,10 @@ CREATE TABLE `deletedbiblio` ( -- stores information about bibliographic records
   `frameworkcode` varchar(4) NOT NULL default '', -- foriegn key from the biblio_framework table to identify which framework was used in cataloging this record
   `author` LONGTEXT, -- statement of responsibility from MARC record (100$a in MARC21)
   `title` LONGTEXT, -- title (without the subtitle) from the MARC record (245$a in MARC21)
+  `medium` LONGTEXT, -- medium from the MARC record (245$h in MARC21)
+  `subtitle` LONGTEXT, -- remainder of the title from the MARC record (245$b in MARC21)
+  `part_number` LONGTEXT, -- part number from the MARC record (245$n in MARC21)
+  `part_name` LONGTEXT, -- part name from the MARC record (245$p in MARC21)
   `unititle` LONGTEXT, -- uniform title (without the subtitle) from the MARC record (240$a in MARC21)
   `notes` LONGTEXT, -- values from the general notes field in the MARC record (500$a in MARC21) split by bar (|)
   `serial` tinyint(1) default NULL, -- Boolean indicating whether biblio is for a serial
@@ -579,7 +559,6 @@ CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrower
   `contactname` LONGTEXT, -- used for children and profesionals to include surname or last name of guarantor or organization name
   `contactfirstname` MEDIUMTEXT, -- used for children to include first name of guarantor
   `contacttitle` MEDIUMTEXT, -- used for children to include title (Mr., Mrs., etc) of guarantor
-  `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarantors or organizations
   `borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client
   `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor
   `sex` varchar(1) default NULL, -- patron/borrower's gender
@@ -609,6 +588,7 @@ CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrower
   `lang` varchar(25) NOT NULL default 'default', -- lang to use to send notices to this patron
   `login_attempts` int(4) default 0, -- number of failed login attemps
   `overdrive_auth_token` MEDIUMTEXT default NULL, -- persist OverDrive auth token
+  `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization
   KEY borrowernumber (borrowernumber),
   KEY `cardnumber` (`cardnumber`),
   KEY `sms_provider_id` (`sms_provider_id`)
@@ -740,7 +720,6 @@ CREATE TABLE `import_records` (
   `status` enum('error', 'staged', 'imported', 'reverted', 'items_reverted', 'ignored') NOT NULL default 'staged',
   `import_error` LONGTEXT,
   `encoding` varchar(40) NOT NULL default '',
-  `z3950random` varchar(40) default NULL,
   PRIMARY KEY (`import_record_id`),
   CONSTRAINT `import_records_ifbk_1` FOREIGN KEY (`import_batch_id`)
              REFERENCES `import_batches` (`import_batch_id`) ON DELETE CASCADE ON UPDATE CASCADE,
@@ -865,17 +844,6 @@ CREATE TABLE `issuingrules` ( -- circulation and fine rules
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 --
--- Table structure for table `refund_lost_item_fee_rules`
---
-
-DROP TABLE IF EXISTS `refund_lost_item_fee_rules`;
-CREATE TABLE `refund_lost_item_fee_rules` ( -- refund lost item fee rules tbale
-  `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode)
-  `refund` tinyint(1) NOT NULL default 0, -- control wether to refund lost item fees on return
-  PRIMARY KEY  (`branchcode`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
 -- Table structure for table `items`
 --
 
@@ -970,21 +938,6 @@ CREATE TABLE `itemtypes` ( -- defines the item types
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 --
--- Table structure for table `default_branch_item_rules`
---
-
-DROP TABLE IF EXISTS `default_branch_item_rules`;
-CREATE TABLE `default_branch_item_rules` (
-  `itemtype` varchar(10) NOT NULL,
-  `holdallowed` tinyint(1) default NULL,
-  hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode
-  `returnbranch` varchar(15) default NULL,
-  PRIMARY KEY  (`itemtype`),
-  CONSTRAINT `default_branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`)
-    ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
 -- Table structure for table `branchtransfers`
 --
 
@@ -1007,25 +960,6 @@ CREATE TABLE `branchtransfers` ( -- information for items that are in transit be
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 --
--- Table structure for table `branch_item_rules`
---
-
-DROP TABLE IF EXISTS `branch_item_rules`;
-CREATE TABLE `branch_item_rules` ( -- information entered in the circulation and fine rules under 'Holds policy by item type'
-  `branchcode` varchar(10) NOT NULL, -- the branch this rule is for (branches.branchcode)
-  `itemtype` varchar(10) NOT NULL, -- the item type this rule applies to (items.itype)
-  `holdallowed` tinyint(1) default NULL, -- the number of holds allowed
-  hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode
-  `returnbranch` varchar(15) default NULL, -- the branch the item returns to (homebranch, holdingbranch, noreturn)
-  PRIMARY KEY  (`itemtype`,`branchcode`),
-  KEY `branch_item_rules_ibfk_2` (`branchcode`),
-  CONSTRAINT `branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`)
-    ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `branch_item_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
-    ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
 -- Table structure for table `creator_images`
 --
 
@@ -1114,7 +1048,7 @@ CREATE TABLE `marc_subfield_structure` (
   `authtypecode` varchar(20) default NULL,
   `value_builder` varchar(80) default NULL,
   `isurl` tinyint(1) default NULL,
-  `hidden` tinyint(1) default NULL,
+  `hidden` tinyint(1) NOT NULL default 8,
   `frameworkcode` varchar(4) NOT NULL default '',
   `seealso` varchar(1100) default NULL,
   `link` varchar(80) default NULL,
@@ -1613,7 +1547,6 @@ CREATE TABLE `borrowers` ( -- this table includes information about your patrons
   `contactname` LONGTEXT, -- used for children and profesionals to include surname or last name of guarantor or organization name
   `contactfirstname` MEDIUMTEXT, -- used for children to include first name of guarantor
   `contacttitle` MEDIUMTEXT, -- used for children to include title (Mr., Mrs., etc) of guarantor
-  `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarantors or organizations
   `borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client
   `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor
   `sex` varchar(1) default NULL, -- patron/borrower's gender
@@ -1643,12 +1576,12 @@ CREATE TABLE `borrowers` ( -- this table includes information about your patrons
   `lang` varchar(25) NOT NULL default 'default', -- lang to use to send notices to this patron
   `login_attempts` int(4) default 0, -- number of failed login attemps
   `overdrive_auth_token` MEDIUMTEXT default NULL, -- persist OverDrive auth token
+  `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization
   UNIQUE KEY `cardnumber` (`cardnumber`),
   PRIMARY KEY `borrowernumber` (`borrowernumber`),
   KEY `categorycode` (`categorycode`),
   KEY `branchcode` (`branchcode`),
   UNIQUE KEY `userid` (`userid`),
-  KEY `guarantorid` (`guarantorid`),
   KEY `surname_idx` (`surname` (191)),
   KEY `firstname_idx` (`firstname` (191)),
   KEY `othernames_idx` (`othernames` (191)),
@@ -1881,6 +1814,7 @@ CREATE TABLE `reserves` ( -- information related to holds/reserves in Koha
   `suspend` BOOLEAN NOT NULL DEFAULT 0,
   `suspend_until` DATETIME NULL DEFAULT NULL,
   `itemtype` VARCHAR(10) NULL DEFAULT NULL, -- If record level hold, the optional itemtype of the item the patron is requesting
+  `item_level_hold` BOOLEAN NOT NULL DEFAULT 0, -- Is the hpld placed at item level
   PRIMARY KEY (`reserve_id`),
   KEY priorityfoundidx (priority,found),
   KEY `borrowernumber` (`borrowernumber`),
@@ -1920,6 +1854,7 @@ CREATE TABLE `old_reserves` ( -- this table holds all holds/reserves that have b
   `suspend` BOOLEAN NOT NULL DEFAULT 0, -- in this hold suspended (1 for yes, 0 for no)
   `suspend_until` DATETIME NULL DEFAULT NULL, -- the date this hold is suspended until (NULL for infinitely)
   `itemtype` VARCHAR(10) NULL DEFAULT NULL, -- If record level hold, the optional itemtype of the item the patron is requesting
+  `item_level_hold` BOOLEAN NOT NULL DEFAULT 0, -- Is the hpld placed at item level
   PRIMARY KEY (`reserve_id`),
   KEY `old_reserves_borrowernumber` (`borrowernumber`),
   KEY `old_reserves_biblionumber` (`biblionumber`),
@@ -1981,21 +1916,17 @@ CREATE TABLE `statistics` ( -- information related to transactions (circulation
   `value` double(16,4) default NULL, -- monetary value associated with the transaction
   `type` varchar(16) default NULL, -- transaction type (localuse, issue, return, renew, writeoff, payment)
   `other` LONGTEXT, -- used by SIP
-  `usercode` varchar(10) default NULL, -- unused in Koha
   `itemnumber` int(11) default NULL, -- foreign key from the items table, links transaction to a specific item
   `itemtype` varchar(10) default NULL, -- foreign key from the itemtypes table, links transaction to a specific item type
   `location` varchar(80) default NULL, -- authorized value for the shelving location for this item (MARC21 952$c)
   `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table, links transaction to a specific borrower
-  `associatedborrower` int(11) default NULL, -- unused in Koha
   `ccode` varchar(80) default NULL, -- foreign key from the items table, links transaction to a specific collection code
   KEY `timeidx` (`datetime`),
   KEY `branch_idx` (`branch`),
   KEY `type_idx` (`type`),
-  KEY `usercode_idx` (`usercode`),
   KEY `itemnumber_idx` (`itemnumber`),
   KEY `itemtype_idx` (`itemtype`),
   KEY `borrowernumber_idx` (`borrowernumber`),
-  KEY `associatedborrower_idx` (`associatedborrower`),
   KEY `ccode_idx` (`ccode`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
@@ -2113,8 +2044,8 @@ CREATE TABLE `subscriptionhistory` (
   `histenddate` date default NULL,
   `missinglist` LONGTEXT NOT NULL,
   `recievedlist` LONGTEXT NOT NULL,
-  `opacnote` varchar(150) NOT NULL default '',
-  `librariannote` varchar(150) NOT NULL default '',
+  `opacnote` LONGTEXT NULL,
+  `librariannote` LONGTEXT NULL,
   PRIMARY KEY  (`subscriptionid`),
   KEY `biblionumber` (`biblionumber`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
@@ -2461,7 +2392,9 @@ CREATE TABLE `tmp_holdsqueue` (
   `holdingbranch` varchar(10) default NULL,
   `pickbranch` varchar(10) default NULL,
   `notes` MEDIUMTEXT,
-  `item_level_request` tinyint(4) NOT NULL default 0
+  `item_level_request` tinyint(4) NOT NULL default 0,
+  CONSTRAINT `tmp_holdsqueue_ibfk_1` FOREIGN KEY (`itemnumber`)
+    REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 --
@@ -2678,7 +2611,7 @@ CREATE TABLE `accountlines` (
   `date` date default NULL,
   `amount` decimal(28,6) default NULL,
   `description` LONGTEXT,
-  `accounttype` varchar(5) default NULL,
+  `accounttype` varchar(16) default NULL,
   `status` varchar(16) default NULL,
   `payment_type` varchar(80) default NULL, -- optional authorised value PAYMENT_TYPE
   `amountoutstanding` decimal(28,6) default NULL,
@@ -3262,19 +3195,6 @@ CREATE TABLE aqorders_transfers (
   CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
---
--- Table structure for table `fieldmapping`
---
-
-DROP TABLE IF EXISTS `fieldmapping`;
-CREATE TABLE `fieldmapping` ( -- koha to keyword mapping
-  `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
-  `field` varchar(255) NOT NULL, -- keyword to be mapped to (ex. subtitle)
-  `frameworkcode` char(4) NOT NULL default '', -- foreign key from the biblio_framework table to link this mapping to a specific framework
-  `fieldcode` char(3) NOT NULL, -- marc field number to map to this keyword
-  `subfieldcode` char(1) NOT NULL, -- marc subfield associated with the fieldcode to map to this keyword
-  PRIMARY KEY  (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 --
 -- Table structure for table `transport_cost`
@@ -3314,7 +3234,7 @@ CREATE TABLE `biblioimages` ( -- local cover images
 
 DROP TABLE IF EXISTS `social_data`;
 CREATE TABLE IF NOT EXISTS `social_data` (
-  `isbn` VARCHAR(30),
+  `isbn` VARCHAR(30) NOT NULL DEFAULT '',
   `num_critics` INT,
   `num_critics_pro` INT,
   `num_quotations` INT,
@@ -3396,6 +3316,7 @@ CREATE TABLE borrower_attribute_types_branches( -- association table between bor
 CREATE TABLE IF NOT EXISTS `borrower_modifications` (
   `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
   `verification_token` varchar(255) NOT NULL DEFAULT '',
+  `changed_fields` MEDIUMTEXT NOT NULL DEFAULT '',
   `borrowernumber` int(11) NOT NULL DEFAULT '0',
   `cardnumber` varchar(32) DEFAULT NULL,
   `surname` LONGTEXT,
@@ -3440,7 +3361,6 @@ CREATE TABLE IF NOT EXISTS `borrower_modifications` (
   `contactname` LONGTEXT,
   `contactfirstname` MEDIUMTEXT,
   `contacttitle` MEDIUMTEXT,
-  `guarantorid` int(11) DEFAULT NULL,
   `borrowernotes` LONGTEXT,
   `relationship` varchar(100) DEFAULT NULL,
   `sex` varchar(1) DEFAULT NULL,
@@ -3535,6 +3455,17 @@ CREATE TABLE patron_consent (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 --
+-- Table structure for table 'plugin_methods'
+--
+
+DROP TABLE IF EXISTS plugin_methods;
+CREATE TABLE plugin_methods (
+  plugin_class varchar(255) NOT NULL,
+  plugin_method varchar(255) NOT NULL,
+  PRIMARY KEY ( `plugin_class` (191), `plugin_method` (191) )
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+--
 -- Table structure for table `patron_lists`
 --
 
@@ -4139,6 +4070,21 @@ CREATE TABLE IF NOT EXISTS club_fields (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 --
+-- Table structure for table 'guarantors_guarantees'
+--
+
+DROP TABLE IF EXISTS borrower_relationships;
+CREATE TABLE `borrower_relationships` (
+      id INT(11) NOT NULL AUTO_INCREMENT,
+      guarantor_id INT(11) NULL DEFAULT NULL,
+      guarantee_id INT(11) NOT NULL,
+      relationship VARCHAR(100) NOT NULL,
+      PRIMARY KEY (id),
+      CONSTRAINT r_guarantor FOREIGN KEY ( guarantor_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE,
+      CONSTRAINT r_guarantee FOREIGN KEY ( guarantee_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+--
 -- Table structure for table `illrequests`
 --
 
@@ -4327,6 +4273,17 @@ CREATE TABLE stockrotationitems (
       ON UPDATE CASCADE ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
+--
+-- Table structure for table `keyboardshortcuts`
+--
+
+DROP TABLE IF EXISTS `keyboard_shortcuts`;
+CREATE TABLE keyboard_shortcuts (
+shortcut_name varchar(80) NOT NULL,
+shortcut_keys varchar(80) NOT NULL,
+PRIMARY KEY (shortcut_name)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
 /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
 /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;