Lines 1-15
Link Here
|
1 |
$DBversion = 'XXX'; # will be replaced by the RM |
1 |
$DBversion = 'XXX'; # will be replaced by the RM |
2 |
if( CheckVersion( $DBversion ) ) { |
2 |
if( CheckVersion( $DBversion ) ) { |
3 |
|
3 |
|
4 |
$dbh->do(q| |
4 |
my $sth = $dbh->prepare(q|SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_NAME='accountlines_ibfk_1'|); |
5 |
ALTER TABLE accountlines DROP FOREIGN KEY accountlines_ibfk_1; |
5 |
$sth->execute; |
6 |
|); |
6 |
if ($sth->fetchrow_hashref) { |
7 |
$dbh->do(q| |
7 |
$dbh->do(q| |
8 |
ALTER TABLE accountlines CHANGE COLUMN borrowernumber borrowernumber INT(11) DEFAULT NULL; |
8 |
ALTER TABLE accountlines DROP FOREIGN KEY accountlines_ibfk_1; |
9 |
|); |
9 |
|); |
10 |
$dbh->do(q| |
10 |
$dbh->do(q| |
11 |
ALTER TABLE accountlines ADD CONSTRAINT accountlines_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE SET NULL ON UPDATE CASCADE; |
11 |
ALTER TABLE accountlines CHANGE COLUMN borrowernumber borrowernumber INT(11) DEFAULT NULL; |
12 |
|); |
12 |
|); |
|
|
13 |
$dbh->do(q| |
14 |
ALTER TABLE accountlines ADD CONSTRAINT accountlines_ibfk_borrowers FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE SET NULL ON UPDATE CASCADE; |
15 |
|); |
16 |
} |
13 |
|
17 |
|
14 |
SetVersion( $DBversion ); |
18 |
SetVersion( $DBversion ); |
15 |
print "Upgrade to $DBversion done (Bug 21065 - Set ON DELETE SET NULL on accountlines.borrowernumber)\n"; |
19 |
print "Upgrade to $DBversion done (Bug 21065 - Set ON DELETE SET NULL on accountlines.borrowernumber)\n"; |