From a687c7faeadbb6c9f500841f34a03fde9c9ad688 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 24 Jul 2018 09:01:33 -0300 Subject: [PATCH] Bug 18887: Fix DB structure issues - Make atomic update idempotent - Correct COLLAT (atomic update) - Add index on rule_name (kohastructure.sql) - Add rule_name to the unique constraint (kohastructure.sql) - Remove max_holds columns (kohastructure.sql) --- installer/data/mysql/atomicupdate/bug_18887.perl | 34 +++++++++++++----------- installer/data/mysql/kohastructure.sql | 7 +++-- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_18887.perl b/installer/data/mysql/atomicupdate/bug_18887.perl index 07ee2d357f..85da1d207e 100644 --- a/installer/data/mysql/atomicupdate/bug_18887.perl +++ b/installer/data/mysql/atomicupdate/bug_18887.perl @@ -1,22 +1,24 @@ $DBversion = 'XXX'; # will be replaced by the RM if( CheckVersion( $DBversion ) ) { - $dbh->do(q{ - CREATE TABLE `circulation_rules` ( - `id` int(11) NOT NULL auto_increment, - `branchcode` varchar(10) NULL default NULL, - `categorycode` varchar(10) NULL default NULL, - `itemtype` varchar(10) NULL default NULL, - `rule_name` varchar(32) NOT NULL, - `rule_value` varchar(32) NOT NULL, - PRIMARY KEY (`id`), - KEY `branchcode` (`branchcode`), - KEY `categorycode` (`categorycode`), - KEY `itemtype` (`itemtype`), - KEY `rule_name` (`rule_name`), - UNIQUE (`branchcode`,`categorycode`,`itemtype`,`rule_name`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - }); + unless (TableExists('circulation_rules')){ + $dbh->do(q{ + CREATE TABLE `circulation_rules` ( + `id` int(11) NOT NULL auto_increment, + `branchcode` varchar(10) NULL default NULL, + `categorycode` varchar(10) NULL default NULL, + `itemtype` varchar(10) NULL default NULL, + `rule_name` varchar(32) NOT NULL, + `rule_value` varchar(32) NOT NULL, + PRIMARY KEY (`id`), + KEY `branchcode` (`branchcode`), + KEY `categorycode` (`categorycode`), + KEY `itemtype` (`itemtype`), + KEY `rule_name` (`rule_name`), + UNIQUE (`branchcode`,`categorycode`,`itemtype`,`rule_name`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + }); + } $dbh->do(q{ INSERT INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value ) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index e6dd950856..c540a1ce01 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -350,7 +350,6 @@ CREATE TABLE `branch_borrower_circ_rules` ( -- includes default circulation rule `categorycode` VARCHAR(10) NOT NULL, -- the patron category this rule applies to (categories.categorycode) `maxissueqty` int(4) default NULL, -- the maximum number of checkouts this patron category can have at this branch `maxonsiteissueqty` int(4) default NULL, -- the maximum number of on-site checkouts this patron category can have at this branch - max_holds INT(4) NULL DEFAULT NULL, -- the maximum number of holds a patron may have at a time PRIMARY KEY (`categorycode`, `branchcode`), CONSTRAINT `branch_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -367,7 +366,6 @@ CREATE TABLE `default_borrower_circ_rules` ( -- default checkout rules found und `categorycode` VARCHAR(10) NOT NULL, -- patron category this rul `maxissueqty` int(4) default NULL, `maxonsiteissueqty` int(4) default NULL, - max_holds INT(4) NULL DEFAULT NULL, -- the maximum number of holds a patron may have at a time PRIMARY KEY (`categorycode`), CONSTRAINT `borrower_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE @@ -4208,8 +4206,9 @@ CREATE TABLE `circulation_rules` ( KEY `branchcode` (`branchcode`), KEY `categorycode` (`categorycode`), KEY `itemtype` (`itemtype`), - UNIQUE (`branchcode`,`categorycode`,`itemtype`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + KEY `rule_name` (`rule_name`), + UNIQUE (`branchcode`,`categorycode`,`itemtype`,`rule_name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -- 2.11.0