From 510b7e68d2c3869bf66d933dde84c59fc1aa371e Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Mon, 4 Apr 2011 11:20:20 +0000 Subject: [PATCH] Bug 5860: Adding duplicate stocknumber fails silently When adding a duplicate stocknumber the duplicate was not saved to the database. This happened, because the field stocknumber in table items was declared to be unique. Discussion on bug suggests to lift this restriction. Signed-off-by: Marcel de Rooy Tested. Corrected typo in updatedatabase script. Version 3.01.00.095 introduced the index with double s, although structure had only one s in index name. Unaware of this bug, I entered the more general bug 6041 for similar problems with modifying items. Signed-off-by: Chris Cormack (cherry picked from commit a8ffb2273b63c398492a7cbd08394adedb2aeadb) Signed-off-by: Chris Nighswonger --- installer/data/mysql/kohastructure.sql | 2 +- installer/data/mysql/updatedatabase.pl | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 8c6317e9bf..77555935c7 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1020,7 +1020,7 @@ CREATE TABLE `items` ( `stocknumber` varchar(32) default NULL, PRIMARY KEY (`itemnumber`), UNIQUE KEY `itembarcodeidx` (`barcode`), - UNIQUE KEY `itemstocknumberidx` (`stocknumber`), + KEY `itemstocknumberidx` (`stocknumber`), KEY `itembinoidx` (`biblioitemnumber`), KEY `itembibnoidx` (`biblionumber`), KEY `homebranch` (`homebranch`), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index c3f867d458..f231703f0a 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4015,6 +4015,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = '3.03.00.XXX'; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("ALTER TABLE `items` DROP INDEX `itemsstocknumberidx`;"); + $dbh->do("ALTER TABLE items ADD INDEX itemstocknumberidx (stocknumber);"); + print "Upgrade to $DBversion done (Change items.stocknumber to be not unique)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 DropAllForeignKeys($table) -- 2.39.5