Bug #59697 Forward Engineer CREATE with multiple schemas causes problems for ALTER
Submitted: 24 Jan 2011 15:03 Modified: 14 Jun 2013 0:57
Reporter: Daniel Hallgren Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: Modeling Severity:S3 (Non-critical)
Version:5.2.31a OS:Any
Assigned to: Assigned Account CPU Architecture:Any

[24 Jan 2011 15:03] Daniel Hallgren
Description:
In Workbench 5.1, when using Forward Engineer CREATE, everything related to one schema was grouped together, with a "CREATE SCHEMA IF NOT EXISTS" at the beginning of each group. 

In Workbench 5.2, all "CREATE SCHEMA IF NOT EXISTS" are placed at the beginning of the resulting DDL file, instead of just before the DDL for that schema.

Forward Engineer ALTER does not behave like it should when all "CREATE SCHEMA..." rows are located together in the source file. For example, it will add "CREATE TABLE..." for ALL tables in the second schema. It will also not add any "ALTER TABLE..." for the second schema, probably because it thinks all tables are new, even when they are not, and only one table has been modified. 

I have not been able to reproduce the problem with schema's containing only tables, but adding a routine to each schema is enough to trigger it all the time.

How to repeat:
Create a model with two schema's, each containing at least one table and at least one routine. Do a Forward Engineer CREATE, and immediately afterwards do a Forward Engineer ALTER with the first file as source. The resulting DDL contains "CREATE TABLE..." for the tables in the second schema, which it should not.

Now open the source file and move the "CREATE SCHEMA IF NOT EXISTS" for the second schema to just below the DDL for the first schema, and do another Forward Engineer ALTER. The resulting DDL is now empty (or as empty as it could be).

Suggested fix:
Restore the behavior for placing "CREATE SCHEMA IF NOT EXISTS" in Forward Engineer CREATE, to how it was in Workbench 5.1.
[24 Jan 2011 16:13] Johannes Taxacher
changed OS info, as its not platform-specific
[14 Jun 2013 0:57] Philip Olson
Fixed as of the upcoming MySQL Workbench 6.0.2 public beta release, and here's the changelog entry:

After executing "Forward Engineer CREATE", all generated "CREATE SCHEMA
IF NOT EXISTS" statements were placed at the beginning of the resulting
DDL file, instead of just before the DDL for each schema.

Thank you for the bug report.