Bug #47202 Workbench doesn't create DROP/CREATE statements for multiple schemas
Submitted: 8 Sep 2009 23:53 Modified: 26 Nov 2009 11:32
Reporter: Gary Pendergast Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:5.1.18 SE OS:Windows
Assigned to: Alexander Musienko CPU Architecture:Any

[8 Sep 2009 23:53] Gary Pendergast
Description:
When exporting a Workbench file as an SQL CREATE script, only the CREATE SCHEMA for the first schema is created.

How to repeat:
- Open Worbench
- Create a new schema
- Click on File -> Export -> Forward Engineer SQL CREATE Script...
- Click Next twice

Observe that the 'CREATE SCHEMA' statement only exists for the first schema

Suggested fix:
Create the 'CREATE SCHEMA' statement for all schemas
[9 Sep 2009 20:52] Johannes Taxacher
Hi Gary

could you re-check that behaviour, because WB only creates schema-create-statements if there are objects to be created in the schema as well, so for adding an empty schema this is expected behaviour.

thx
[9 Sep 2009 21:49] Gary Pendergast
Same behaviour if I create a table in each schema as well. The dump file has the CREATE TABLE statements for the tables in each schema, but only has the CREATE SCHEMA statement for the first schema.
[10 Sep 2009 3:53] Valeriy Kravchuk
What operating system you had used? Had you added at least one column to each of the tables?

Attaching .mwb file that demonstrates the problem would be useful. I can NOT repeat this with 5.1.18 on Mac as soon as each table has at least one column.
[10 Sep 2009 11:23] Gary Pendergast
Sample MWB file that causes export problem

Attachment: sample.mwb (, text), 4.19 KiB.

[10 Sep 2009 11:24] Gary Pendergast
Attached sample file. On my computer, exporting this will give all the correct SQL, except the CREATE SCHEMA for new_schema1.

Running 5.1.18 SE on Windows 7 64-bit.
[10 Sep 2009 15:55] Valeriy Kravchuk
On Mac OS X I've got the following with .mwb uploaded:

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';

CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `mydb`;

-- -----------------------------------------------------
-- Table `mydb`.`table1`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`table1` (
  `idtable1` INT NOT NULL ,
  PRIMARY KEY (`idtable1`) )
ENGINE = InnoDB;

CREATE SCHEMA IF NOT EXISTS `new_schema1` ;
USE `new_schema1`;

-- -----------------------------------------------------
-- Table `new_schema1`.`table1`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `new_schema1`.`table1` (
  `idtable1` INT NOT NULL ,
  PRIMARY KEY (`idtable1`) )
ENGINE = InnoDB;

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

So, not repeatable. Will check on Windows tomorrow.
[11 Sep 2009 6:21] Valeriy Kravchuk
Verified just as described on XP with recent file uploaded privately.
[11 Nov 2009 7:58] Susanne Ebrecht
This is still true for Workbench 5.2
[25 Nov 2009 19:04] Johannes Taxacher
fixed in repository. will be included in 5.2.9
[26 Nov 2009 11:32] Tony Bedford
An entry has been added to the 5.2.9 changelog:

When using the Forward Engineer SQL Script wizard, the script generated for a model containing multiple schemata, only included the CREATE SCHEMA statement for the first schema.