Bug #74632 Workbench: Reordering primary key attributes causes primary key to be recreated
Submitted: 30 Oct 2014 9:45 Modified: 30 Oct 2014 12:30
Reporter: Craig Macdonald Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:6.2.3 OS:Any (Tested on Windows, Mac)
Assigned to: CPU Architecture:Any
Tags: table editor

[30 Oct 2014 9:45] Craig Macdonald
Description:
The columns named in a primary key form a set. However, if, within Workbench, the attributes that form the primary key are reordered in the table editor, then the primary key is dropped and recreated. This is incorrect, and can cause problems (e.g. if the primary keys are already part of a foreign key.

How to repeat:

Create a table in Workbench to following schema:
CREATE TABLE `table2-compPK` (
  `myPK1` int(11) NOT NULL,
  `myPK2` varchar(45) NOT NULL,
  PRIMARY KEY (`myPK1`,`myPK2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Apply, then enter the Table Editor and drag myPK2 above myPK1.

The following SQL is created

ALTER TABLE `workbenchtest`.`table2-compPK` 
CHANGE COLUMN `myPK1` `myPK1` INT(11) NOT NULL FIRST,
DROP PRIMARY KEY,
ADD PRIMARY KEY (`myPK1`, `myPK2`);

Suggested fix:
I can see code in backend/wbpublic/grtdb/editor_table.cpp that refers to checking for simple order changes of indexes (including primary keys), however I cannot comment on what the bug is.
[30 Oct 2014 12:30] MySQL Verification Team
Thank you for the bug report.