Visualize Your Rails Database Schema for Free on Windows

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!