From f53710493fdb50f5c8b725bdb50a0d027e2c4c5c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 29 Apr 2015 10:15:50 +0200 Subject: [PATCH] Bug 14069: Drop existing primary key on items if exists On old databases, the issues table has a primary key on itemnumber. The DBrev 3.19.00.028 (Bug 13790 - Add unique id issue_id to issues and oldissues tables) has to remove it before adding the new primary key Test plan: 1/ Make sure you have an old DB, or add primary key (issues.itemnumber)manually on a DB created before 3.19.00.028. 2/ Execute the updatedatabase.pl script 3/ You should not get any error and the primary key on itemnumber should have been removed and the new one created as expected. --- installer/data/mysql/updatedatabase.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 5d1b778..1f77ff1 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -10155,6 +10155,13 @@ if ( CheckVersion($DBversion) ) { $DBversion = "3.19.00.028"; if( CheckVersion($DBversion) ) { + eval { + local $dbh->{PrintError} = 0; + $dbh->do(q{ + ALTER TABLE issues DROP PRIMARY KEY + }); + }; + $dbh->do(q{ ALTER TABLE old_issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST }); -- 2.1.0