Bug 23151: Modifiy database structure
[koha-equinox.git] / installer / data / mysql / kohastructure.sql
index b01fb66..62effe9 100644 (file)
@@ -355,34 +355,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`
 --
 
@@ -609,7 +581,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
-  `flgAnonymized` tinyint DEFAULT 0, -- flag for data anonymization
+  `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization
   KEY borrowernumber (borrowernumber),
   KEY `cardnumber` (`cardnumber`),
   KEY `sms_provider_id` (`sms_provider_id`)
@@ -741,7 +713,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,
@@ -866,17 +837,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`
 --
 
@@ -971,21 +931,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`
 --
 
@@ -1008,25 +953,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`
 --
 
@@ -1644,7 +1570,7 @@ 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
-  `flgAnonymized` tinyint DEFAULT 0, -- flag for data anonymization
+  `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization
   UNIQUE KEY `cardnumber` (`cardnumber`),
   PRIMARY KEY `borrowernumber` (`borrowernumber`),
   KEY `categorycode` (`categorycode`),
@@ -1883,6 +1809,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`),
@@ -1922,6 +1849,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`),
@@ -1983,21 +1911,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;
 
@@ -2115,8 +2039,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;
@@ -2463,7 +2387,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;
 
 --
@@ -2680,7 +2606,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,
@@ -3316,7 +3242,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,
@@ -3398,6 +3324,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,
@@ -3537,6 +3464,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`
 --
 
@@ -4329,6 +4267,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 */;