|
Line 0
Link Here
|
|
|
1 |
$DBversion = 'XXX'; |
| 2 |
if( CheckVersion( $DBversion ) ) { |
| 3 |
|
| 4 |
if( TableExists( 'hold_group' ) ){ |
| 5 |
$dbh->do(q{UPDATE reserves SET hold_group_id = NULL}); |
| 6 |
$dbh->do(q{UPDATE old_reserves SET hold_group_id = NULL}); |
| 7 |
|
| 8 |
$dbh->do(q{ALTER TABLE reserves DROP FOREIGN KEY reserves_ibfk_6}); |
| 9 |
$dbh->do(q{ALTER TABLE old_reserves DROP FOREIGN KEY old_reserves_ibfk_5}); |
| 10 |
|
| 11 |
$dbh->do(q{DROP TABLE hold_group}); |
| 12 |
$dbh->do(q{CREATE TABLE hold_group ( |
| 13 |
hold_group_id int unsigned NOT NULL AUTO_INCREMENT, |
| 14 |
PRIMARY KEY (hold_group_id) |
| 15 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci}); |
| 16 |
} |
| 17 |
|
| 18 |
unless( column_exists( 'reserves', 'hold_group_id' ) ){ |
| 19 |
$dbh->do(q{ALTER TABLE reserves ADD COLUMN hold_group_id int unsigned NULL DEFAULT NULL}); |
| 20 |
} |
| 21 |
unless( column_exists( 'old_reserves', 'hold_group_id') ){ |
| 22 |
$dbh->do(q{ALTER TABLE old_reserves ADD COLUMN hold_group_id int unsigned NULL DEFAULT NULL}); |
| 23 |
} |
| 24 |
|
| 25 |
unless( foreign_key_exists( 'reserves', 'reserves_ibfk_6' ) ){ |
| 26 |
$dbh->do(q{ALTER TABLE reserves ADD CONSTRAINT reserves_ibfk_6 FOREIGN KEY (hold_group_id) REFERENCES hold_group (hold_group_id) ON DELETE SET NULL ON UPDATE CASCADE}); |
| 27 |
} |
| 28 |
unless( foreign_key_exists( 'old_reserves', 'old_reserves_ibfk_5' ) ){ |
| 29 |
$dbh->do(q{ALTER TABLE old_reserves ADD CONSTRAINT old_reserves_ibfk_5 FOREIGN KEY (hold_group_id) REFERENCES hold_group (hold_group_id) ON DELETE SET NULL ON UPDATE CASCADE}); |
| 30 |
} |
| 31 |
|
| 32 |
SetVersion( $DBversion ); |
| 33 |
print "Upgrade to $DBversion done (Bug 15516 - Adding hold group table)\n"; |
| 34 |
} |