$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 )
`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,
`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
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 */;