Tuesday, June 14, 2011

Generate rails from a ERD ?

This isn't much of a blog post, it's a question !  I love ERDs (Entity Relationship Diagrams)  for database design and have been known to produce them before the database or the code .  Recently I've been doing a lot of work in Ruby on Rails which generates the database and model code for you, hiding the database under a ORM layer.  This is all very well and good  but you can see my problem.  No longer can I build  a ERD, check it's normalisation  nd optimise it with a bit of de-normalisation.

So, the question is:

Is there a tool out there that will take a ERD and generate the rails commands to build a app from the ERD.  I mean create the models and generate the migrations at least  ?

Suppose you had an ERD like this:


When I want to generate rails this would do something like the following

rails generate scaffold Person name:string
rails generate scaffold Town name:string<
rake db:migrate

It would then go in and alter the model for Person to set up the relationship to town.


Answers on a postcard !