@@ -, +, @@ old_issues.issue_id --- installer/data/mysql/atomicupdate/bug_18185.perl | 10 ++++++++++ installer/data/mysql/kohastructure.sql | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_18185.perl --- a/installer/data/mysql/atomicupdate/bug_18185.perl +++ a/installer/data/mysql/atomicupdate/bug_18185.perl @@ -0,0 +1,10 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + unless ( column_exists( 'old_issues', 'id' ) ) { + $dbh->do(q|ALTER TABLE old_issues DROP PRIMARY KEY|); + $dbh->do(q|ALTER TABLE old_issues ADD COLUMN id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST|); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 18185 - Add new column old_issues.id as primary key)\n"; +} --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -1763,7 +1763,8 @@ CREATE TABLE `issues` ( -- information related to check outs or issues DROP TABLE IF EXISTS `old_issues`; CREATE TABLE `old_issues` ( -- lists items that were checked out and have been returned - `issue_id` int(11) NOT NULL, -- primary key for issues table + `id` int(11) NOT NULL AUTO_INCREMENT, -- primary key for old_issues table + `issue_id` int(11) NOT NULL, -- primary key from the issues table `borrowernumber` int(11) default NULL, -- foreign key, linking this to the borrowers table for the patron this item was checked out to `itemnumber` int(11) default NULL, -- foreign key, linking this to the items table for the item that was checked out `date_due` datetime default NULL, -- date the item is due (yyyy-mm-dd) @@ -1776,7 +1777,7 @@ CREATE TABLE `old_issues` ( -- lists items that were checked out and have been r `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched `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`), + PRIMARY KEY (`id`), KEY `old_issuesborridx` (`borrowernumber`), KEY `old_issuesitemidx` (`itemnumber`), KEY `branchcode_idx` (`branchcode`), --