Remove itemstocknumber index and recreate it.
---
 installer/data/mysql/updatedatabase.pl |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/installer/data/mysql/updatedatabase.pl 
b/installer/data/mysql/updatedatabase.pl
index f503112..d802f8e 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -4323,6 +4323,19 @@ if (C4::Context->preference("Version") < 
TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
+$DBversion = '3.04.00.XXX';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    #Follow up fix for 5860
+    #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 (non unique)
+    $dbh->do("ALTER TABLE items ADD INDEX itemstocknumberidx (stocknumber);");
+    print "Upgrade to $DBversion done (5860: Change items.stocknumber to be 
not unique)\n";
+    SetVersion ($DBversion);
+}
 
 =head1 FUNCTIONS
 
-- 
1.6.0.6

_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to