Bug #62189 Synchronize with any source reverses source/destinations
Submitted: 17 Aug 2011 10:44 Modified: 1 Sep 2011 20:19
Reporter: Anders Stalheim Øfsdahl Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: Modeling Severity:S2 (Serious)
Version:5.2.34 OS:Windows (7)
Assigned to: CPU Architecture:Any

[17 Aug 2011 10:44] Anders Stalheim Øfsdahl
Description:
When trying to synchronize two databases against each other using the "synchronize with any source", the resulting alter script is totally wrong as the selected source becomes the destination, and vice-versa.

How to repeat:
Run the following script:

CREATE DATABASE `example_source`;
CREATE TABLE `example_source`.`dummy` (foo INT);
CREATE DATABASE `example_destination`;
CREATE TABLE `example_destination`.`dummy` (bar INT);

Select a model file, then 'Synchronize with any source'. Select 'example_source' as the source and 'example_destination' as the destination.

The generated alter SQL is:

DROP SCHEMA IF EXISTS `example_source` ;
CREATE SCHEMA IF NOT EXISTS `example_destination`;
USE `example_destination`;
CREATE  TABLE IF NOT EXISTS `example_destination`.`dummy`(
  `bar` INT(11) NULL DEFAULT NULL
)

But this is wrong, the source is supposed to be syncronized to the destination, not the other way around. The correct alter SQL would have been:

DROP SCHEMA IF EXISTS `example_destination` ;
CREATE SCHEMA IF NOT EXISTS `example_source`;
USE `example_source`;
CREATE  TABLE IF NOT EXISTS `example_source`.`dummy`(
  `foo` INT(11) NULL DEFAULT NULL
)

Suggested fix:
Correctly remember what database is the source and what is the destination.
[17 Aug 2011 10:46] Anders Stalheim Øfsdahl
Selecting the source

Attachment: selecting_source.png (image/png, text), 30.42 KiB.

[17 Aug 2011 10:47] Anders Stalheim Øfsdahl
Selecting the destination

Attachment: selecting_destination.png (image/png, text), 30.73 KiB.

[17 Aug 2011 10:47] Anders Stalheim Øfsdahl
Source and destination is reversed

Attachment: source_and_destination_mixed_up.png (image/png, text), 28.55 KiB.

[26 Aug 2011 15:05] Armando Lopez Valencia
Thank you very much for your report Anders.
Reproduced exactly as the reported stated.
[1 Sep 2011 20:19] Philip Olson
Fixed as of 5.2.35:

+        The <guilabel>Synchronize with Any Source</guilabel> option
+        reversed the 'destination' and 'source' database names within
+        the generated SQL statement.