Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Oh 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.


I 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: