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 2841-2847 CREATE TABLE `alert` ( Link Here
2841
  `externalid` varchar(20) NOT NULL default '',
2841
  `externalid` varchar(20) NOT NULL default '',
2842
  PRIMARY KEY  (`alertid`),
2842
  PRIMARY KEY  (`alertid`),
2843
  KEY `borrowernumber` (`borrowernumber`),
2843
  KEY `borrowernumber` (`borrowernumber`),
2844
  KEY `type` (`type`,`externalid`)
2844
  KEY `type` (`type`,`externalid`),
2845
  CONSTRAINT alert_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON UPDATE CASCADE ON DELETE CASCADE
2845
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2846
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2846
2847
2847
--
2848
--
2848
- 

Return to bug 13535