So far, it\’s RoR

Ruby on Rails, PostgreSQL, SVN, etc….

Visualize your Rails database schema for free on Windows

Posted by Chirag Patel on August 9, 2007

Using Railroad and Graphviz

Blog update (10/22/2007): Thanks to the comment posted by Blog de Kilgore, I tried Railroad (instead of using the below method with starUML) to visualize my RoR app. Very easy to setup and use (see examples on web page).

Here’s a quick command to create a .png graphic file of your models:

    railroad -a -i -M | dot -Tpng > models.png


This command will directly write to a .png file without the need of Graphviz

  1. Database Models
  2. Mailer models
  3. Observer models
  4. Associations (with lines and arrows)
  5. Inheritance among classes (for regular models, mailers, and observers)



Using starUML

Rails keeps your schema is a file called db/schema.rb (which I assume is updated every time you run a Rails migration). To visualize your schema in Windows:

  1. Install and run the following plugin to convert your schema (db/schema.rb) to an XML format:

    This will generate schema.xml (uses a open standard fromat called XMI).

  2. Download the latest version of starUML for Windows (Version 5.0, released Dec 29, 2005). StarUML is a “software modeling tool and also platform that is a compelling replacement of commercial UML tools such as Rational Rose
    • Open schema.xml from starUML’s Import -> XMI (I chose “Design Model” when importing, but it doesn’t really matter)
    • starUML
    • Go to the Model Explorer (under Design Model”) and drag each table to the design surface

Thanks to Miroslav Škultéty for writing the script and cnruby for converting into a plugin!


One Response to “Visualize your Rails database schema for free on Windows”

  1. […] L’excellent plugins rav n’étant plus maintenu, son auteur conseille de s’orienter vers railroad qui fourni des fonctionnalités similaires. Même si ce nouveau plugin génère des graphiques un peu moins lisible, il n’en reste pas moins un outil indispensable pour documenter facilement un projet sans forcément utiliser StarUML et exporter son schéma selon les conseils de ce blog. […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: