Skip to content

Instantly share code, notes, and snippets.

@ranginui
Created April 19, 2011 11:01
Show Gist options
  • Save ranginui/927131 to your computer and use it in GitHub Desktop.
Save ranginui/927131 to your computer and use it in GitHub Desktop.
$DBversion = '3.03.00.xxx';
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
my $sth = $dbh->prepare("SHOW INDEX FROM items WHERE KEY_NAME = 'itemsstocknumberidx'");
$sth->execute();
if (my $index = $sth->fetchrow_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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment