Bug #54176 Can't change final PK sequence before forward engineering
Submitted: 2 Jun 2010 10:05 Modified: 29 Jul 2010 9:25
Reporter: Susanne Ebrecht Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: Modeling Severity:S3 (Non-critical)
Version:5.2.21 OS:Linux (Ubuntu)
Assigned to: Alfredo Kojima CPU Architecture:Any

[2 Jun 2010 10:05] Susanne Ebrecht
Description:
I will add some screenshots so that you will understand what I mean.

Open Workbench
Create new model
Delete mydb
Create new schema mytest collation utf8_unicode_ci
Add diagram
Add Innodb table named my like given in pk_forward_bug_screen1.png.
Database -> Forward Enginnering
Mark Drop objects before each create object.

Now show to the output pk_forward_bug_screen2.png.
PRIMARY KEY (`z`, `f`, `r`, `a`) 
That is exactly how I added the sequence in my model.

PRESS CANCEL

Let us say you figured out that sequence is wrong. You want to change it.

Drag and drop column 'a' between 'f' and 'r'. To get PK(z,f,a,r).
See here pk_forward_bug_screen3.png.

After that you should have scenario of pk_forward_bug_screen4.png.

Database -> Forward Enginnering
Look into the output; pk_forward_bug_screen5.png.

You will see that Workbench wants to create PK(z,f,r,a) instead of PK(z,f,a,r).

When you will execute the statement now you will figure out that it is really executed with wrong PK column sequence. 

How to repeat:
See above

Suggested fix:
...
[2 Jun 2010 10:06] Susanne Ebrecht
screen 1

Attachment: pk_forward_bug_screen1.png (image/png, text), 69.71 KiB.

[2 Jun 2010 10:07] Susanne Ebrecht
screen 2

Attachment: pk_forward_bug_screen2.png (image/png, text), 56.27 KiB.

[2 Jun 2010 10:07] Susanne Ebrecht
screen 3

Attachment: pk_forward_bug_screen3.png (image/png, text), 70.89 KiB.

[2 Jun 2010 10:08] Susanne Ebrecht
screen 4

Attachment: pk_forward_bug_screen4.png (image/png, text), 69.70 KiB.

[2 Jun 2010 10:08] Susanne Ebrecht
screen 5

Attachment: pk_forward_bug_screen5.png (image/png, text), 56.57 KiB.

[6 Jul 2010 0:07] Alfredo Kojima
Fixed so that PRIMARY index is reordered automatically when columns are reordered. Other indexes are left untouched.
[27 Jul 2010 13:00] Johannes Taxacher
fix confirmed in repository
[29 Jul 2010 9:25] Tony Bedford
An entry has been added to the 5.2.26 changelog:

In forward engineering a model to a database, the PRIMARY index was not reordered correctly when columns were reordered.