Rails schema browser plugin: proof of concept

Posted on February 12, 2008

I have just created my first rails plugin which is a proof of concept interactive graphical viewer for your database schema and relations. It is still very rough around the edges and I have not had as much time as I hoped due to starting a great job at Naked. I'm expecting to make some time for this soon though.

For an example of what you might expect see the schema browser of my own mephisto blog. Tables are drawn based on the tables defined in the current database and relations based on the belongs_to relations defined in the models.

Installing the schema_browser plugin:

cd yourapp/vendor/plugins
git clone git://github.com/tomtt/schema-browser.git
cd ../../
./script/generate schema_browser

Things may work for you this way, but it is also totally possible that you will have to add corresponding routes to config/routes.rb:

  map.connect 'schema_browser', :controller => "schema_browser"
  map.connect 'schema_browser/schema', :controller => "schema_browser", :action => "schema"

If you have to do this, you may also have to restart your server.

The schema browser is now available at http://yoursite.com/schema_browser. Note that currently this would be shown in production as well which may not be something you want. Disabling the schema browser in production is one of many future plans for this plugin.
The xml representation is available at http://yoursite.com/schema_browser/schema

The javascript code to view this was taken from http://ondras.zarovi.cz/sql/ which is an amazing piece of work.

I'd be interested to hear if it is possible to serve up a git repos as if it were an svn repos so that script/plugin install would still work.

Real programmers

Posted on February 01, 2008

If you have geeky personal tendencies, you should know about xkcd. Here's a recent strip featuring my favourite editor.

By the way, xkcd mouse overs are the funniest bit sometimes, but firefox does not show them out of the box. Fortunately this is fixed by the Long Titles extension.