MySQL Workbench Propel export plugin v0.4


I finally came around to update the Workbench propel export plugin. Sorry that it took so long.

This is what is new:

  • Added support to set database baseClass manually
  • Added support to set phpName per table manually
  • DATETIME type is converted to TIMESTAMP type
  • Added support for onDelete and onUpdate foreign key constraints (based on work by Antoine Noal aka Hvannentir)
  • size and scale support for DECIMAL columns (based on work by Antoine Noal aka Hvannentir)
  • support for multiple foreign key references (thanks for pointing that out Antoine!)

The first to features where added because I want to have other PHP-names than what propel generates automatically (Table named customers but class name should be Customer). I also have a custom baseClass injected in the inheritance tree to be able implement generic features for all my objects, so I needed the baseClass attribute. – Not beeing able to set this from the workbench export meant that I had to patch the generated schema file on every update with a small script which corrected the issues. With the new features I can now omit that extra step.
To use the baseClass-functionality, just use the new menu-entry “PropelExport: Set custom baseClass” inside Plugins -> Catalog.
To use the phpName-functionality, simply right-click on a table and use “PropelExport: Set custom phpName”.
Important to note: If you want to remove a previously set baseClass or phpName, enter one empty space as name. (I had to do this because of a shortcoming of MySQL Workbench, which does not enable me to differentiate between an entered empty string or a press on cancel).
The entered names are also saved in the Workbench file, so subsequent exports will automatically contain them. If you want to see the entered values, just run the corresponding menu-entry. The currently set text is displayed in paranthesis only in the title-bar of the dialog. (Another shortcoming in the used Workbench:input method.) Simply press cancel to keep the original text.

The DATETIME issue was fixed by me long ago, but I forgot to post the new version, so 0.4 also contains this fix.

The other features are mostly based on the work of Antoine Noal, although I did some small improvements/corrections. Thanks again for your work, Antoine!

Download Link: MySQL Workbench Propel-Export Plugin v0.4
(Be sure to reload the file if it still shows the 0.3 version)

If you have questions regarding the new features or you find bugs / have suggestions, don’t hesitate to leave a comment!

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Hy dhaas !

I have found a little bug. Mediumint is not converted to int by the plugin and propel does not understand it.
Except that, the v0.4 works fine with my schema and propel 1.2 integrated in symfony 1.0.
Great work.

Thanks again for submitting a bug!
I fixed it and released this as 0.4.1, the download was updated. If you downloaded the plugin before, just download it again, if you haven’t yet, you will automatically get the fixed version.

Hi, thanks for this cool plugin !
I works like a charm with Porpel 1.3beta4.

I had just two very small issues, one with DECIMAL fields and one with generating UNIQUE constraints on INTEGER fields.

Here’s the adjustments I made :
465c465
elseif (currentColumn.simpleType==”DECIMAL”) then
527,529c527
< if (column.referencedColumn.length ~= -1) then
< xml:addAttribute(‘size’,column.referencedColumn.length)
xml:addAttribute(‘size’,column.referencedColumn.length

Cheers,
Costin

“I had to do this because of a shortcoming of MySQL Workbench, which does not enable me to differentiate between an entered empty string or a press on cancel”… great programming! It shows it’s always good to read the comments.

Hi, thanks for this plugin,
I have error alert plugin v0.4.1 “21:24:26 | Error executing plugin: Error calling lua function PropelExport.exportPropelSchemaToClipboard: ‘…Roaming\MySQL\Workbench\modules\PropelExport.grt.lua:513: List index out of bounds’”

Hi, thx for the plugin!

Does it work with propel 1.3 correctly?

Yes, it works with Propel 1.3, however it does not support Propel 1.3 specific features such as the defaultExpr column attribute.
If you don’t need this features, the plugin should suit your needs perfectly.

@Maciej:
You seem to have a foreign key defined which does not reference a column in the foreign table. Check all your foreign key declarations to see if they are complete.

Have you ever tried to run the plugin in MySQL Workbench 5.1.x? It’s not working!

The plugin locations changed from MySQL Workbench 5.0 to 5.1+. You must move them to some %APPDATA%\MySQL\modules dir (Windows).

BOOLEAN and BOOL type is UNKNOWN when using version 5.1

Have been using the plugin for about a year now with Propel 1.3. Now, Propel 1.4 has been released (http://propel.phpdb.org/trac/wiki/Users/Documentation/1.4). Generating classes using the Workbench plugin with the Propel 1.4 fails with the following error message:

[PHP Error] DateTime::__construct(): Failed to parse time string (NOW()) at position 3 ((): Unexpected character [line 133 of [...]\Propel\current\generator\classes\propel\engine\builder\om\php5\PHP5ObjectBuilder.php]
[PHP Error] DateTime::__construct(): Failed to parse time string (NULL) at position 0 (N): The timezone could not be found in the
database [line 133 of [...]\Propel\current\generator\classes\propel\engine\builder\om\php5\PHP5ObjectBuilder.php]

Any chance, we will see a new plugin version soon?

The plugin has been updated to Version 0.5: http://www.diloc.de/blog/2009/10/14/mysql-workbench-propel-export-plugin-v05/

@Hardeep Khehra: Fixed in new version
@Frank: I suppose this is a Propel 1.4-Bug. Propel 1.4 is not yet released, its an alpha. If this problem persists after 1.4 is released I will have a look at it.

in reply to comment #12 and 13:

After thorough testing, it might in fact be a Propel bug (even in Propel version 1.3). Please refer to the following post for more details:

http://groups.google.com/group/propel-users/browse_thread/thread/ef747974b8d459db?hl=en#