4 ms·
That's pretty cool. Basically including the best parts of ActiveAttr into ActiveRecord. :) Maybe someday we won't have to write migrations anymore. Rails could
by tomphoolery 11y ago
That's pretty cool. Basically including the best parts of ActiveAttr into ActiveRecord. :)
Maybe someday we won't have to write migrations anymore. Rails could maybe just diff the attributes and types given, and figure out the schema itself.
- thirdsun 11y agoOh yes, I always though it would make more sense to setup columns in the model itself, without migrations. Also, no more need for the annotate gem.
- pmontra 11y agoI see your point but the implementation must be very well designed. There are migrations that can take hours to complete in production. Examples: adding an index to a very large table or adding an element to an enum (I remember a customer of mine had this problem on a MySQL db a couple of years ago.) A DSL that makes clear you are modifying the db is a safeguard against those surprises. Just adding something like indexed: true to an attribute declaration would be dangerous. Furthermore rake migrate:up/down are more convenient than reverting a change to a model by checking out an older version. I believe that it's not impossible to do it, but it must be designed very carefully. Maybe because of those reasons Phoenix, the Rails like web framework for Elixir, has migrations even if models declare the attributes of the tables in the database.
- xentronium 11y agoThat's what original datamapper did. There are several problems with this approach, and basically you need to have a migration mechanism anyway.