[Rails] Generating SQL from model and not vice versa

Corey Lawson corey.ssf.lawson at gmail.com
Tue Mar 1 21:35:55 GMT 2005


For Windows, an excellent ER diagramming tool (non-$0.00), is "DeZign
for Databases", by datanamic, especially for generating database
creation scripts for multiple target databases from one design.

The one thing it doesn't do too well is recognize that a given field
is an "autoinc" field populated by a trigger that grabs numbers from a
sequence/generator (Oracle, Interbase), and when converting the
diagram to target a database that does support autoinc fields (SQL
Server, MySQL), just translate that construct to an autoinc field type
modifier. If you convert from Oracle to MySQL, you'll lose the trigger
& generator calls. If you then translate back to Oracle, you'll have
to put them back in...  Not sure if Dia or ReKall will catch this.

Also, the free version of ReKall (thekompany.com) might work, too.

There are others, including Visio, ER-Win, etc.

-Corey Lawson

On Tue, 01 Mar 2005 09:03:34 +0800, Meng Kuan
<mengkuan at littlegreenapples.com> wrote:
> On Mon, 2005-02-28 at 23:17 +1100, Dave Burt wrote:
> > A DBMS-independent schema definition language (DDL) could solve this problem.
> > How does DBI do at this?
> > How about Rails' code? I'm not sure how much of the logic that would be needed
> > for that already exists in ActiveRecord adapters (data types, etc.); maybe not
> > too more is needed.
> 
> A workaround that I use to create DBMS-independent schema definitions is
> to:
> 
> 1. draw UML diagrams in dia (http://www.gnome.org/projects/dia/) that
> models the database tables
> 
> 2. use tedia2sql to generate database-specific SQL DDL scripts
> (http://tedia2sql.tigris.org/)
> 
> Of course this is only useful at the beginning of my development when
> the data model is continuously changing. I wrote a simple shell script
> that drops and recreates the entire database from the dia file. Plus it
> helps to have an up-to-date UML diagram of your application.
> 
> cheers,
> mengkuan
> 
> 
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


More information about the Rails mailing list