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

(-)a/installer/data/mysql/atomicupdate/bug_25089_1_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 25089 - Add new circulation rule scope checkout_type )\n";
21
}
(-)a/installer/data/mysql/kohastructure.sql (-2 / +2 lines)
Lines 4415-4420 CREATE TABLE `circulation_rules` ( Link Here
4415
  `branchcode` varchar(10) NULL default NULL,
4415
  `branchcode` varchar(10) NULL default NULL,
4416
  `categorycode` varchar(10) NULL default NULL,
4416
  `categorycode` varchar(10) NULL default NULL,
4417
  `itemtype` varchar(10) NULL default NULL,
4417
  `itemtype` varchar(10) NULL default NULL,
4418
  `checkout_type` ENUM('CHECKOUT', 'ONSITE') NULL default NULL,
4418
  `rule_name` varchar(32) NOT NULL,
4419
  `rule_name` varchar(32) NOT NULL,
4419
  `rule_value` varchar(32) NOT NULL,
4420
  `rule_value` varchar(32) NOT NULL,
4420
  PRIMARY KEY (`id`),
4421
  PRIMARY KEY (`id`),
Lines 4422-4428 CREATE TABLE `circulation_rules` ( Link Here
4422
  CONSTRAINT `circ_rules_ibfk_2` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE,
4423
  CONSTRAINT `circ_rules_ibfk_2` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE,
4423
  CONSTRAINT `circ_rules_ibfk_3` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
4424
  CONSTRAINT `circ_rules_ibfk_3` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
4424
  KEY `rule_name` (`rule_name`),
4425
  KEY `rule_name` (`rule_name`),
4425
  UNIQUE (`branchcode`,`categorycode`,`itemtype`,`rule_name`)
4426
  UNIQUE (`branchcode`,`categorycode`,`itemtype`,`checkout_type`,`rule_name`)
4426
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4427
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4427
4428
4428
--
4429
--
4429
- 

Return to bug 25089