MySQL Workbench + propel = useful


This is the first in a series of posts describing the way DiLoc|Rail is built.

As already mentioned i use MySQL Workbench to develop the database schema for DiLoc|Rail. Since I got to know Ruby on Rails some years ago, I was reluctant to write the whole database code for the backend of the app manually, I was in search for something similar. Something which does the hard work, so that i can concentrate on the real problems. Since I did not want the whole package as Ruby on Rails is, the Ruby on Rails clones where no option. So I finally found propel. Propel concentrates on the model in MVC (Model-View-Controller) and is an ORM (Object Relational Mapper) For propel to understand your database, you have to write a schema-file in XML. (There is also an option for reverse engineering the database, but I left that out because it has its own problems). Since I already had a model in MySQL Workbench, I needed a way to convert the workbench file to a propel readable schema.

Over the DBDesigner4 to Propel XSL I got to a version for Workbench by Josh Bryan which was a great start, but it only worked with the alpha versions of workbench. I adapted it to work with the beta versions and also improved it quite a bit, to save even more information to the propel schema. Now it supports:

  • all datatypes that MySQL Workbench and propel have in common
  • propel required attribute
  • propel default values
  • autoIncrement attribute
  • foreign key relations
  • multiple indexes, both primary and unique

Since workbenchs file format is really ugly i was not able to let it work properly if a graphical model is inside the workbench schema. This is due to the weird value/link-tag behaviour mentioned in the last article. I’m playing with the idea of writing a plugin for MySQL Workbench to directly save as propel schema, which should be even easier, but documentation on that matter is sparse at best. - But for now, this solution works satisfyingly.

If anyone is interested, write a comment and ask for the XSL. If many people are interested I would also consider to build a small webservice around it so that you can upload your MySQL Workbench file and get your propel schema for download.

So this was the first part in the series. Next time we will look at how to improve that even more and add some glue to the mix.

Information and Links

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


Other Posts
How to submit Ext forms the right way
How not to use XML!

Write a Comment

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

Reader Comments

Hi there,

that sounds really interesting, I’m missing exactly the same functionality in Workbench to export Propel schemas. Though my favour is Symfony… ;-)

Great job.

Unfortunatly they still did not document the plugin interface, so I am still stuck with the suboptimal solution I use.
If you are interested in the XSL I could send it to you…

[...] And that with fairly basic models. For me, this makes Workbench nearly pointless. (Fortunatly I can convert the model to a propel schema for use in PHP and let propel generate the tables. - Propel works better in that regard because it [...]

It’s great to see somebody has taken this and made it better. Excellent work!

hi dhaas,

It would be grate to have a service to transfor workbench files to propel xml.

If it’s not possible could you send me the xsl.

Congartulations for your work.

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

@alex: I have now written a native plugin for MySQL Workbench to export files to propel-schema files. Read more about it at: http://www.diloc.de/blog/2008/05/27/mysql-workbench-propel-export-plugin/

Hi Daniel, great job, i am interested by the xsl too. May be it would be cool to share it somewhere.

See you. COil

Hi, If you realy want to simplify your work with Propel XML files, you could try ORM Designer (http://www.orm-designer.com). It’s a fully visual ERD editor with native support for Propel ORM framework (also for Doctrine, CakePHP,…). You can design all objects and attributes in ORMD and then simply press “Export” and all propel.xml files will be generated ;-)

@Ludek Vodicka:
Thanks for the hint! But we use Workbench also to easily create schema-update-files (migrations) since Propel does not support this natively.