From de11726bd5258189e6a84c2921610e135f23174e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 9 Mar 2017 15:53:20 -0300 Subject: [PATCH] Bug 18242: [SOLUTION 1]DB changes - remove PK on 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 diff --git a/installer/data/mysql/atomicupdate/bug_18185.perl b/installer/data/mysql/atomicupdate/bug_18185.perl new file mode 100644 index 0000000..3b444da --- /dev/null +++ b/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"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 91e6119..99023e9 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/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`), -- 2.9.3