aaron.harnly.net

From DTD to Rails Migrations

In the category of tools that I want, but better not make right now, lest it turn into a “paroxysm of generalization”:

I have a DTD, describing a bunch of entities, their relationships, and their attributes. I’m going to push data from a set of XML files (adhering to said DTD) into a Ruby-on-Rails savvy database. Wouldn’t be nice to have a simple tool that, in the most general way possible, would, given that DTD:

  1. Issue a series of ’script/general model Foo’ commands for the various entities.

  2. Populate the Rails migration files appropriately, to manage the creation of the database tables for these entities. That would include inserting :foo_id columns for has-many and has-and-belongs-to-many relationships (though differentiating between the two might require some human supervision), and exploiting the wonderful Red Hill Foreign Key Migrations to create appropriate FK constraints.

  3. In addition / as an alternative to using the Red Hill plugin, insert the appropriate has_many / habtm declarations in the model files.

  4. And finally, make a script that can read a set of such XML files and fill the database appropriately.

Well, sounds nice to me, anyway. Put it on the someday-maybe list.

Digg this     Create a del.icio.us Bookmark     Add to Newsvine

No Responses to “From DTD to Rails Migrations”

No comments yet

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word