@@ -, +, @@ --- installer/data/mysql/updatedatabase.pl | 42 ++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 10 deletions(-) --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -10801,12 +10801,34 @@ if ( CheckVersion($DBversion) ) { LEFT JOIN course_items USING(ci_id) WHERE course_items.ci_id IS NULL }); - $dbh->do(q{ - ALTER IGNORE TABLE course_reserves - add CONSTRAINT course_reserves_ibfk_2 - FOREIGN KEY (ci_id) REFERENCES course_items (ci_id) - ON DELETE CASCADE ON UPDATE CASCADE - }); + my @row; + @row = $dbh->selectrow_arrayref(qq| + SHOW INDEXES FROM course_reserves WHERE key_name='course_reserves_ibfk_2' + |); + #Add fk only if not present + unless ( @row ) { + $dbh->do(q{ + ALTER IGNORE TABLE course_reserves + add CONSTRAINT course_reserves_ibfk_2 + FOREIGN KEY (ci_id) REFERENCES course_items (ci_id) + ON DELETE CASCADE ON UPDATE CASCADE + }); + }else{ + $dbh->do(q{ + ALTER IGNORE TABLE course_reserves + DROP FOREIGN KEY course_reserves_ibfk_2; + }); + $dbh->do(q{ + ALTER IGNORE TABLE course_reserves + DROP INDEX course_reserves_ibfk_2; + }); + $dbh->do(q{ + ALTER IGNORE TABLE course_reserves + add CONSTRAINT course_reserves_ibfk_2 + FOREIGN KEY (ci_id) REFERENCES course_items (ci_id) + ON DELETE CASCADE ON UPDATE CASCADE + }); + }; print "Upgrade to $DBversion done (Bug 14205: Deleting an Item/Record does not remove link to course reserve)\n"; SetVersion($DBversion); } @@ -10869,7 +10891,7 @@ if ( CheckVersion($DBversion) ) { $DBversion = "3.21.00.027"; if ( CheckVersion($DBversion) ) { $dbh->do(q| - INSERT INTO permissions (module_bit, code, description) + INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (1, 'self_checkout', 'Perform self checkout at the OPAC. It should be used for the patron matching the AutoSelfCheckID') |); @@ -11264,11 +11286,11 @@ if ( CheckVersion($DBversion) ) { CREATE TABLE audio_alerts ( id int(11) NOT NULL AUTO_INCREMENT, precedence smallint(5) unsigned NOT NULL, - selector varchar(255) NOT NULL, - sound varchar(255) NOT NULL, + selector varchar(255) COLLATE utf8_unicode_ci NOT NULL, + sound varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (id), KEY precedence (precedence) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; }); $dbh->do(q{ --