Bug 21065: Set ON DELETE SET NULL on accountlines.borrowernumber
Note: Why do we have ON UPDATE SET NULL on accountlines.itemnumber? Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
457e560a06
commit
7f322d7ff8
2 changed files with 18 additions and 2 deletions
16
installer/data/mysql/atomicupdate/bug_21065.perl
Normal file
16
installer/data/mysql/atomicupdate/bug_21065.perl
Normal file
|
@ -0,0 +1,16 @@
|
|||
$DBversion = 'XXX'; # will be replaced by the RM
|
||||
if( CheckVersion( $DBversion ) ) {
|
||||
|
||||
$dbh->do(q|
|
||||
ALTER TABLE accountlines DROP FOREIGN KEY accountlines_ibfk_1;
|
||||
|);
|
||||
$dbh->do(q|
|
||||
ALTER TABLE accountlines CHANGE COLUMN borrowernumber borrowernumber INT(11) DEFAULT NULL;
|
||||
|);
|
||||
$dbh->do(q|
|
||||
ALTER TABLE accountlines ADD CONSTRAINT accountlines_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|);
|
||||
|
||||
SetVersion( $DBversion );
|
||||
print "Upgrade to $DBversion done (Bug 21065 - Set ON DELETE SET NULL on accountlines.borrowernumber)\n";
|
||||
}
|
|
@ -2705,7 +2705,7 @@ DROP TABLE IF EXISTS `accountlines`;
|
|||
CREATE TABLE `accountlines` (
|
||||
`accountlines_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`issue_id` int(11) NULL DEFAULT NULL,
|
||||
`borrowernumber` int(11) NOT NULL default 0,
|
||||
`borrowernumber` int(11) DEFAULT NULL,
|
||||
`accountno` smallint(6) NOT NULL default 0,
|
||||
`itemnumber` int(11) default NULL,
|
||||
`date` date default NULL,
|
||||
|
@ -2722,7 +2722,7 @@ CREATE TABLE `accountlines` (
|
|||
KEY `acctsborridx` (`borrowernumber`),
|
||||
KEY `timeidx` (`timestamp`),
|
||||
KEY `itemnumber` (`itemnumber`),
|
||||
CONSTRAINT `accountlines_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `accountlines_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `accountlines_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
|
|
Loading…
Reference in a new issue