Bug #38488 | Duplicate relationships from DBDesigner models cause create script to fail | ||
---|---|---|---|
Submitted: | 31 Jul 2008 12:24 | Modified: | 5 Aug 2008 13:41 |
Reporter: | Simon Hodgson | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Workbench | Severity: | S2 (Serious) |
Version: | 5.0.23 | OS: | Any |
Assigned to: | Sergei Tkachenko | CPU Architecture: | Any |
[31 Jul 2008 12:24]
Simon Hodgson
[31 Jul 2008 12:47]
Valeriy Kravchuk
Thank you for a problem report. Please, upload a DBDesigner model that demonstrates the behaviour described.
[31 Jul 2008 12:54]
Simon Hodgson
DBDesigner model that will fail
Attachment: example.xml (text/xml), 22.51 KiB.
[1 Aug 2008 7:09]
Simon Hodgson
Please see attached file
[1 Aug 2008 8:39]
Valeriy Kravchuk
Verified just as described with your model. I've got this in the export script generated: mysql> CREATE TABLE IF NOT EXISTS `mydb`.`usr` ( -> `usr_id` INT UNSIGNED NOT NULL AUTO_INCREMENT , -> `grp_id` INT UNSIGNED NOT NULL , -> `company_id` INT UNSIGNED NOT NULL , -> `name` VARCHAR(45) NULL , -> PRIMARY KEY (`usr_id`) , -> CONSTRAINT `relation` -> FOREIGN KEY (`company_id` ) -> REFERENCES `mydb`.`company` (`company_id` ), -> CONSTRAINT `relation` -> FOREIGN KEY (`grp_id` ) -> REFERENCES `mydb`.`grp` (`grp_id` )) -> PACK_KEYS = 0 -> ROW_FORMAT = DEFAULT; ERROR 1061 (42000): Duplicate key name 'relation'
[1 Aug 2008 19:13]
Sergei Tkachenko
FK constraint name in WB can't be empty. This requirement is implied by feature of synchronization with DBMS (it must be possible to map server side FK into model's one). That's why DBD4 importer was changed to generate unique name for every foreign key constraint. So now create statement for `usr` table will look the following way: CREATE TABLE `usr` ( `usr_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `grp_id` int(10) unsigned NOT NULL, `company_id` int(10) unsigned NOT NULL, `name` varchar(45) DEFAULT NULL, PRIMARY KEY (`usr_id`), KEY `usr_FKIndex1` (`company_id`), KEY `usr_FKIndex2` (`grp_id`), CONSTRAINT `fk_{B6BD8B58-41D1-412C-8341-4E0304E815D6}` FOREIGN KEY (`company_id`) REFERENCES `company` (`company_id`), CONSTRAINT `fk_{8F5CBA50-BED9-4207-AD54-68C0CA7315C4}` FOREIGN KEY (`grp_id`) REFERENCES `grp` (`grp_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 PACK_KEYS=0
[1 Aug 2008 19:20]
Sergei Tkachenko
And currently as a workaround you can change FK names manually. You should change the name of the foreign key itself through table editor instead of the caption of corresponding relation on diagram.
[1 Aug 2008 21:37]
Johannes Taxacher
now WB generates uniqe constraint identifier when importing FKs from DBD4 documents. this will go into 5.0.24
[5 Aug 2008 13:41]
Tony Bedford
An entry was added to the 5.0.24 changelog: When a DBDesigner 4 model that contained duplicate relationships was imported into Workbench, and then exported, the resultant script would fail when executed on MySQL server.