I am pretty sure this has been brought up elsewhere, and have heard it
discussed a few places myself.
I want to know what thoughts surround the concept of having ActiveRecord
have methods such as
class Model < ActiveRecord::Base
column :first_name, :string => 255
column :description, :text
column :created_on, :datetime
column :random_number, :integer
column :cost, :float
end
Basically as you can see, the active record will have a new method called
column, which defines the data model within. Now, ActiveRecord could also be
kept the same, where-by if a column is not defined, it simply introspects
the database and uses that, but if a column is defined, it ensures that the
column has been created and matches the data type set. If the column has not
been created, when that model is loaded, the table is appended to and the
column added. If that column name already exists, such as
"first_name", but
is let''s say, only a varchar(40) instead of a varchar(255) as defined
in the
model above, then the column method will log an error, or could be defined
to cause an application segfault and halt the system until that has been
corrected.
I have heard that this may be part of Nitro, but from my perspective, may be
worth having in Rails/ActiveRecord as well. This seems like a pretty sweet
place to be able to create your app. Basically, you could write nothing but
Ruby/Rails, and your application would be generated from the ground up. All
it would need is a valid DB connection. Migrations would work, and even the
models themselves would work without migrations.
Some may argue that this should be done in Migrations, and may well be the
case. But is worth discussing alternatives, and finding out if this is worth
investigating (and yes David, as a plugin!).
-Nb
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Nathaniel S. H. Brown http://nshb.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~