@@ -, +, @@ +show create table issues; +show create table issues; --- installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/updatedatabase.pl | 10 ++++++++++ 2 files changed, 11 insertions(+) --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -1144,6 +1144,7 @@ CREATE TABLE `issues` ( -- information related to check outs or issues `issuedate` datetime default NULL, -- date the item was checked out or issued `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag PRIMARY KEY (`issue_id`), + UNIQUE KEY `itemnumber` (`itemnumber`), KEY `issuesborridx` (`borrowernumber`), KEY `itemnumber_idx` (`itemnumber`), KEY `branchcode_idx` (`branchcode`), --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -11054,6 +11054,16 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = 'XXX'; +if ( CheckVersion($DBversion) ) { + my $create_table_issues = @{ $dbh->selectall_arrayref(q|SHOW CREATE TABLE issues|) }[0]->[1]; + if ($create_table_issues !~ m|UNIQUE KEY.*itemnumber| ) { + $dbh->do(q|ALTER TABLE issues ADD CONSTRAINT UNIQUE KEY (itemnumber)|); + } + print "Update to $DBversion done (Bug 14978: Make sure issues.itemnumber is a unique key)\n"; + SetVersion($DBversion); +} + # DEVELOPER PROCESS, search for anything to execute in the db_update directory # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. --