So, you start out with a rails app, and you’ve got a database and
models. And when you use a model object, it infers a bunch of stuff
from the database. But then your database needs to change, so you
write a migration to manage that. But now you’re not really inferring
structure from the database, you’re getting it from the migration, and
the database is the intermediary.
Doesn’t it make sense then to integrate the migrations into the model
directly? Is there some reason why this wasn’t done?
Among other things, if they were, you could have conditional code in
the model that depended on particular migration versions - things like
“if you’re on version N of the schema which includes a price field,
then add methods to compute the tax” or some such.
So, if you have a migration, it’s used, and if not, then it falls back
to inferring from the db structure the same way it works now.
** Expert Technical Project and Business Management
**** System Performance Analysis and Architecture
****** [ http://www.adamfields.com ]