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

(-)a/installer/data/mysql/atomicupdate/bug_13535_alert_constraint.perl (+16 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    unless ( foreign_key_exists( 'alert', 'alert_ibfk_1' ) ) {
4
        $dbh->do(q|
5
            DELETE a FROM alert a
6
            LEFT JOIN borrowers b ON a.borrowernumber=b.borrowernumber
7
            WHERE b.borrowernumber IS NULL
8
        |);
9
        $dbh->do(
10
            qq{
11
            ALTER TABLE alert ADD CONSTRAINT alert_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON UPDATE CASCADE ON DELETE CASCADE
12
              }
13
        );
14
    }
15
    NewVersion( $DBversion, 13535, "Add FK constraint on borrowernumber to alert table");
16
}
(-)a/installer/data/mysql/kohastructure.sql (-2 / +2 lines)
Lines 2830-2836 CREATE TABLE `alert` ( Link Here
2830
  `externalid` varchar(20) NOT NULL default '',
2830
  `externalid` varchar(20) NOT NULL default '',
2831
  PRIMARY KEY  (`alertid`),
2831
  PRIMARY KEY  (`alertid`),
2832
  KEY `borrowernumber` (`borrowernumber`),
2832
  KEY `borrowernumber` (`borrowernumber`),
2833
  KEY `type` (`type`,`externalid`)
2833
  KEY `type` (`type`,`externalid`),
2834
  CONSTRAINT alert_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON UPDATE CASCADE ON DELETE CASCADE
2834
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2835
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2835
2836
2836
--
2837
--
2837
- 

Return to bug 13535