From 939b9c67f99776eff72f8f18cac29f0c73662f6d Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Sat, 21 Nov 2015 12:42:00 +0100 Subject: [PATCH] Bug 15207: Follow-up - change check for existing index --- installer/data/mysql/updatedatabase.pl | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index c97dee2..9a9ea1a 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -10802,15 +10802,12 @@ if ( CheckVersion($DBversion) ) { WHERE course_items.ci_id IS NULL }); my $dbconfigured = C4::Context->config("database"); - my $count_course_reserves_ibfk_2 = $dbh->selectrow_arrayref(qq| - SELECT COUNT(*) - FROM information_schema.table_constraints - WHERE table_schema = '$dbconfigured' - AND table_name = 'course_reserves' - AND CONSTRAINT_NAME = 'course_reserves_ibfk_2' + 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 - if ( $count_course_reserves_ibfk_2-->[0] == 0) { + unless ( @row ) { $dbh->do(q{ ALTER IGNORE TABLE course_reserves add CONSTRAINT course_reserves_ibfk_2 -- 1.9.1