View | Details | Raw Unified | Return to bug 25089
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_25089_add_checkout_type_to_circulation_rules.perl (+21 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
4
    if ( ! column_exists( 'circulation_rules', 'checkout_type' ) ) {
5
        $dbh->do( q|
6
            ALTER TABLE circulation_rules ADD COLUMN checkout_type ENUM('CHECKOUT', 'ONSITE') DEFAULT NULL AFTER itemtype;
7
        | );
8
9
        if ( index_exists( 'circulation_rules', 'branchcode' ) ) {
10
            # we need to drop this forgein key before updating our unique index
11
            $dbh->do( "ALTER TABLE `circulation_rules` DROP FOREIGN KEY circ_rules_ibfk_1;" );
12
            $dbh->do( "ALTER TABLE `circulation_rules` DROP INDEX `branchcode`;" );
13
            $dbh->do( "ALTER TABLE `circulation_rules` ADD CONSTRAINT circ_rules_ibfk_1 FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE" );
14
            $dbh->do( "ALTER TABLE `circulation_rules` ADD UNIQUE INDEX (`branchcode`,`categorycode`,`itemtype`,`checkout_type`,`rule_name`)" );
15
        }
16
    }
17
18
    # Always end with this (adjust the bug info)
19
    SetVersion( $DBversion );
20
    print "Upgrade to $DBversion done (Bug 24101 - Add new circulation rule scope checkout_type )\n";
21
}
(-)a/installer/data/mysql/kohastructure.sql (-2 / +2 lines)
Lines 4317-4322 CREATE TABLE `circulation_rules` ( Link Here
4317
  `branchcode` varchar(10) NULL default NULL,
4317
  `branchcode` varchar(10) NULL default NULL,
4318
  `categorycode` varchar(10) NULL default NULL,
4318
  `categorycode` varchar(10) NULL default NULL,
4319
  `itemtype` varchar(10) NULL default NULL,
4319
  `itemtype` varchar(10) NULL default NULL,
4320
  `checkout_type` ENUM('CHECKOUT', 'ONSITE') NULL default NULL,
4320
  `rule_name` varchar(32) NOT NULL,
4321
  `rule_name` varchar(32) NOT NULL,
4321
  `rule_value` varchar(32) NOT NULL,
4322
  `rule_value` varchar(32) NOT NULL,
4322
  PRIMARY KEY (`id`),
4323
  PRIMARY KEY (`id`),
Lines 4324-4330 CREATE TABLE `circulation_rules` ( Link Here
4324
  CONSTRAINT `circ_rules_ibfk_2` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE,
4325
  CONSTRAINT `circ_rules_ibfk_2` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE,
4325
  CONSTRAINT `circ_rules_ibfk_3` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
4326
  CONSTRAINT `circ_rules_ibfk_3` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
4326
  KEY `rule_name` (`rule_name`),
4327
  KEY `rule_name` (`rule_name`),
4327
  UNIQUE (`branchcode`,`categorycode`,`itemtype`,`rule_name`)
4328
  UNIQUE (`branchcode`,`categorycode`,`itemtype`,`checkout_type`,`rule_name`)
4328
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4329
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4329
4330
4330
--
4331
--
4331
- 

Return to bug 25089