MySQL Workbench Propel export plugin

So I wrote about converting MySQL Workbench files to Propel schema files.

Now I have a much improved solution: A plugin for MySQL Workbench that allows you to export your current catalog as Propel schema file.

Like the XSL I wrote, it supports the same features:

  • Columns with:
    • Default values
    • Auto-increment attribute
    • Size
    • Description
    • Required-attribute
    • Primary-key attribute
  • normal extra keys
  • unique keys
  • foreign keys

Currently it creates propel 1.2 compatible files, but I plan to publish an update once propel 1.3 is available as rc.

The plugin allows you to export the propel-schema to the clipboard so that you can paste it everywhere you want, or you may export it to a file. Unfortunatly MySQL Workbench does not yet have a way for plugins to show a “file save as”-dialog, so you have to type the path in manually. I hope the MySQL guys implement a file selector in the next version, as it should be doable quite easily. If that becomes available, I will update the plugin accordingly.

The neat thing is, that the export path is saved inside the Workbench file, so on subsequent exports you have the possibility to overwrite the last file right away without entering a path again.

The plugin certainly contains bugs and shortcomings, but I think it is a good start. If you have a case where the plugin does not export your file correctly, please send me the workbench file and explain what gets exported wrong, and I will hopefully be able to provide a fix for it.

And if you are a lua-monkey then dont hesitate to point me to ways to improve the code of the plugin. This is was my first time experience with lua and as such it may very well be not perfect.

So, without further ado, here is the MySQL Workbench Propel-Export Plugin v0.3.

How to Install:

Copy the file to your modules-folder inside the Workbench installation. This should work in all versions of Windows prior to Vista.
On Vista this may not work due to the automatic directory-redirection. In that case place the file into that folder: C:\Users\<username>\AppData\Roaming\MySQL\Workbench\modules\ and it should work perfectly.

After you placed the file into the directory, simple restart MySQL Workbench and the plugin should show up in the Plugins -> Catalog menu. The two entries from the plugin are prefixed with “PropelExport:” so you should be able to find them easily.

Thats it! Now go ahaed and test the plugin, and report how it works through the comments section! Thanks!

Information and Links

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

Other Posts

Reader Comments

Mmmh. Sounds good. I think i will try the Workbench in the next few Days and also try your plug in. At the moment i still use the old DBDesigner and the XSL for DBD to Propel Transformation.

I quickly tried to export the propel-schema from my model. It worked well for me.
Thank you for this plugin !

Exciting stuff! I think this is the first external plugin for Workbench. I have also posted about this on the official MySQL Workbench blog,

Daniel, you rock!

Ive tried the plugin based on an imported DBDesigner schema.
Some differences with the old XSL transformation came from import trouble ( onDelete, onUpdate ) and others from the plugin : indexes are not present anymore in the transformed schema, DATETIME are set as DATETIME and not TIMESTAMP ( propel version difference ? ), size on decimal field is not present ( like size=”10,2″ ), unique indexes names and unique-column name are missing. On foreign-key constraint on multi-field primary keys, just one field is referenced in the constraint.

And that’s all so far.

So I must continue with DBDesigner and CLI version of the conversion ( Ive integrated it as symfony CLI task ), but I really hope the import of Workbench will get better for foreign-key option ( ondelete ) and your plugin act like the previous XSL transform.

Thanks for your work, its just great.

Sorry indexes are present, but there are more than with the XSL transformation.

Ive modified the plugin in order to correct problems with foreihn-keys ( onDelete, onUpdate, etc .. and the multiple keys trouble ) DATETIME are set as TIMESTAMP, size for decimal is added thanks to precision and scale GRT values, names not present on unique indexes etc ..
The day the import from DBD4 supports onDelete and onUpdate attributes, the export should work just fine.
If you want the corrected version of the export, I will email it to you.

Hi Hvannentir,
Could you send me corrected version of this plugin?

Works great. Thanks a lot, that’s exactly what I was looking for…

Hi, on the last post you said you had fixed some of the problems Hvannentir pointed out, and I’m unsure if you updated the script, so in case you didn’t update, I wonder if you could send me the updated script to my email. Thanks in advance, cheers!


Sorry guys, I was on holidays and forgot to mention that on the blog, so it took so long to approve the comments.
I have not updated the plugin yet, but will do so today and release an updated version containing the fixes of Hvannentir and maybe some more.

Whenever I try and use this plugin I get.

12:49:33 | Error executing plugin: Error calling lua function PropelExport.exportPropelSchemaToClipboard: ‘.\modules\PropelExport.grt.lua:434: List index out of bounds’

Does your update fix this? Am I also able to get this emailed to me?

[…] finally came around to update the Workbench propel export plugin. Sorry that it took so […]

I finally came around to update the export-plugin:
MySQL Workbench Propel export plugin v0.4

@Michael T:
This seems to be a problem with your model and an incomplete foreign-key declaration. Please recheck them and see if all referenced tables are set and not empty.
If you own the SE Version you may also run the different validation scripts to check if you model is well-defined.

Really great plugin, thanks for your work. That’s exactly what i was looking for ! It will save me a lot of time, building my symfony schema.

Perhaps you can tell it to the symfony team. They could add a tip into the documentation of the framework – if it’s not already done..


I’ve got a serious problem here.

When I have a foreign key, in Workbench it is both a “column” and a “foreign key”, so in Propel’s XML it is twice. Therefore a validating routine fails with a message that one of the foreign key’s name collide with a column name. I’m using this with Propel 1.3.

Does your plugin work for the Linux version of MySQL Workbench?
I followed your instructions and I don’t see anything in the Plugins menu.

@Michal Till:
Sorry, but I don’t understand your problem here. It is normal that you cannot name a foreign-key like a column. This is not propel limitation, but a MySQL limitation.

The plugin should also work under Linux, but I have not tested it yet. I think you placed the plugin in the wrong folder. Unfortunatly I do not know what the right location is for linux. It may also be that plugins are not yet supported in the linux-version. You should look for help in the MySQL Workbench forums under:

It doesn’t work under my Linux Fedora9 :(
This is path to modules directory /home/chyrus/.mysql/workbench/modules

Great plugin. Does 80% of the work.

It can’t handle User Types in tables though (can be defined on right-hand side in WB), and it doesnt print out the enum-values. Both are especially handy for serious projects.

Any idea how to extend your plugin to print these ? I have tried, but the learning curve for workbench-lua is a bit steep. There seems to be a field
db_UserDataType though.

Thanks for the effort !

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

I’m having the same problem that Karsten have. The plugin was correctly installed and the workbench asked to restart the program, but nothing, the plugin menu doesn’t show any options. I hope that you can solve this problem.
thanks in advance and congratulations for the idea!

Hi! Great news, i’ve recently tried your plugin on the 5.2.1Alpha version of Workbench and works great. I don’t know why didn’t work on the 5.1.x versions, but i’m happy that works on the new version.

Congratulations for this usefull plugin!

For me it works with Workbench 5.1.12 on Windows. I just installed it in a seperate Folder and the plugin automatically showed up in the menu.
Could you please tell me which version on which operating system you use? If its anything other than Windows, then I expect the cause to be bugs/missing bits in the Operating-System’s version.
Could you please activate the GRT shell after startup and show post the output? Thanks!

Hi dhaas, I was using 5.1.9 version on Windows XP SP3
Here is the output of GRT shell:
Starting Workbench…Registered 142 GRT classes.
Registered 15 modules (from 13 files).
Looking for user plugins in C:\Documents and Settings\Claudio Corlatti\Datos de programa\MySQL\Workbench\modules
Looking for user plugins in C:\Documents and Settings\Claudio Corlatti\Datos de programa\MySQL\Workbench\plugins
ERROR: Module PropelExport had an error while executing getPluginInfo: app.Plugin.groups (which is a container) is read-only

WARNING: Module MysqlSql implements PluginInterface but does not export any plugins

MySQL Generic Runtime Environment 4.1.0
Type ‘help’ or ‘?’ for help. Type ‘quit’ to exit the shell.
Welcome to the Lua Shell.

I’ve just found out, that I was using a beta version so that should be the problem, some missing functionality or something.

Thanks for the plugin! you rock!!

The plugin has been updated to Version 0.5:
@Tilman: User defined types are now supported.