[Koha-patches] [PATCH] [SIGNED-OFF] Bug 5860 - Attempted follow up patch to fix itemstocknumberindex

Marcel de Rooy M.de.Rooy at rijksmuseum.nl
Fri May 13 14:43:20 CEST 2011


From: Chris Cormack <chrisc at catalyst.net.nz>

Signed-off-by: Marcel de Rooy <m.de.rooy at rijksmuseum.nl>
May 13: Replaced information_schema construct with show indexes. Check existence on both names. Tested it.
---
 installer/data/mysql/updatedatabase.pl |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 52951e7..1de273e 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -4217,7 +4217,12 @@ 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`;");
+    #check old indexes and possibly remove
+    my @row = $dbh->selectrow_array("SHOW INDEXES FROM items WHERE key_name='itemstocknumberidx'");
+    $dbh->do("ALTER TABLE `items` DROP INDEX `itemstocknumberidx`;") if @row;
+    @row = $dbh->selectrow_array("SHOW INDEXES FROM items WHERE key_name='itemsstocknumberidx'");
+    $dbh->do("ALTER TABLE `items` DROP INDEX `itemsstocknumberidx`;") if @row;
+    #add index
     $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.6.0.6


More information about the Koha-patches mailing list