From 4e0df0698bedc280d62ef7ff1c527276bb13312a Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Fri, 13 May 2011 14:01:43 +1200 Subject: [PATCH] Bug 5860 - Attempted follow up patch to fix itemstocknumberindex --- installer/data/mysql/updatedatabase.pl | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 52951e7..07bffb5 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4217,7 +4217,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $DBversion = '3.03.00.042'; if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.06.001")) { - $dbh->do("ALTER TABLE `items` DROP INDEX `itemsstocknumberidx`;"); + my $sth = $dbh->prepare("SELECT index_name FROM information_schema.statistics WHERE index_name ='itemsstocknumberidx'"); + $sth->execute(); + if (my $rows = $sth->fetchrows_hashref()){ + $dbh->do("ALTER TABLE `items` DROP INDEX `itemsstocknumberidx`;"); + } + else { + $dbh->do("ALTER TABLE `items` DROP INDEX `itemstocknumberidx`;"); + } $dbh->do("ALTER TABLE items ADD INDEX itemstocknumberidx (stocknumber);"); print "Upgrade to $DBversion done (Change items.stocknumber to be not unique)\n"; SetVersion ($DBversion); -- 1.7.4.1