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)

Signed-off-by: Lisette Scheer <lisetteslatah@gmail.com>

Signed-off-by: Jesse Maseto <jesse@bywatersolution.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2018-07-24 09:01:33 -03:00 committed by Nick Clemens
parent 5c31b9c75e
commit 2eeee4c525
2 changed files with 21 additions and 20 deletions

View File

@ -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 )

View File

@ -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
@ -4224,8 +4222,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 */;