[Rails] Generating SQL from model and not vice versa
Meng Kuan
mengkuan at littlegreenapples.com
Tue Mar 1 01:03:34 GMT 2005
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
More information about the Rails
mailing list