In Django, you fully describe your models in models.py. In Rails with ActiveRecord, you describe a part of one in within the /models directory, and some of it in migrations. Then ActiveRecord introspects model qualities in the existing database tables.
However I find migrations, posts, and tables to become a headache.
How do i do like Django -- just declare all model qualities rather than introspecting them in the database tables?
As well as for extra credit, explain where and why this is an awful idea. :)
Should you hate on Migrations, try going NoSQL. No migrations!
So you'd just add qualities for your document when you really need them. Inside your code, handle the truth that they might not exist and bam!
class Production include MongoMapper::Document key :title, String, :required => true key :slug, String, :unique => true, :required => true, :index => true key :description, String key :notes, String key :price, BigDecimal, :numeric => true key :released_at, Date, :default => Date.today key :default_height, String, :default => '600' key :default_width, String, :default => '1000' key :quotes, String #royalty info key :producers, String timestamps! end
Try the auto_migrations plugin. I do not think it's an awful idea for development, however i would change to migrations after likely to production when there's critical data within the database.
You may even want to consider changing ActiveRecord with DataMapper, which works in Rails 3. It's the design and style you're speaking about, using the description from the data fields of the model within the model code rather than another database schema file.
I believe DataMapper is what you're requesting. Once setup, you'd either use DataMapper.auto_migrate! or DataMapper.auto_upgrade!. The previous will drop tables when they is available before creating them, thus wrecking data. That might be harmful to production. The second is when you avoid losing data, and really should be all right for production.
Not understanding precisely what its doing, I'd guess it's checking tables throughout startup to find out whether or not to make database changes. That may drag lower launch time, especially with many different models/tables. That is really among the top reasons to consider NoSQL - particularly Mongo as pointed out above. It's fast. Really fast, and therefore the beginning up price is much, a smaller amount. MongoMapper is what you want. The tekpub blog post is essential read.
When i first learned about DataMapper in reading through about Merb, so it seems sensible it's in rails 3. I'm not sure whether you might have the ability to have it employed in rails 2.x.