Bug #47765 Synchronize model and unchanged unique keys
Submitted: 1 Oct 2009 15:28 Modified: 2 Oct 2009 7:46
Reporter: Bruno Baketaric Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:5.1.18 OS:Windows
Assigned to: CPU Architecture:Any

[1 Oct 2009 15:28] Bruno Baketaric
Description:
The Bugs also described in Bug-ID 45830 (already marked as closed) is stll present in 5.1.17 SE when using the "Synchronize Model" Function.

I believe the reason is, that WB generates the "ASC" as part of the key, but the MySQL-Server doesn't report the "ASC" since it's the default anyway.

How to repeat:
1) Create this table: 
---snip---
CREATE TABLE IF NOT EXISTS `comb_mt` (
  `id_comb_mt` tinyint(4) NOT NULL auto_increment COMMENT 'ID',
  `fk_id_model` tinyint(3) unsigned NOT NULL COMMENT 'FK Modell',
  `fk_id_trim` tinyint(3) unsigned NOT NULL COMMENT 'FK Trim Level',
  PRIMARY KEY  (`id_comb_mt`),
  UNIQUE KEY `fk_uni_models_trims` (`fk_id_model`,`fk_id_trim`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
---snap---

2) Reverse-Engineer or Recreate the table in(to) WB
3) Sync it with Server using "Synchronize Model"

Result: WB will always try to change the UNIQUE KEY because this is the ALTER Statement it always generates:
ALTER TABLE `db1`.`comb_mt` 
DROP INDEX `fk_uni_models_trims` 
, ADD UNIQUE INDEX `fk_uni_models_trims` (`fk_id_model` ASC, `fk_id_trim` ASC) ;

Suggested fix:
Make the Sync "ASC" (default values) aware.
[1 Oct 2009 15:38] MySQL Verification Team
Thank you for the bug report. Could you please test 5.1.18. Thanks in advance.
[1 Oct 2009 16:33] Bruno Baketaric
Still the same in 5.1.18
[2 Oct 2009 3:30] Valeriy Kravchuk
Looks like this is fixed in 5.2.3, but NOT in 5.1.x.
[2 Oct 2009 6:08] Valeriy Kravchuk
Actually, I can't repeat this with 5.1.18 OSS also. As soon as table is syncronized with database for the first time, subsequent syncronizations do NOT recreate the index. Please, double check.
[2 Oct 2009 7:46] Bruno Baketaric
I attached my Model to Bug-ID 47767. And my Server Version 5.0.77. Perhaps this bug is only present with the Synchronize Model function of the SE Edition.