4 ms·
> I care about the authoritative data model Me too, but the truth about the world is that all inherit complexity is accompanied by incidental complexity :-/ Yo
by snprbob86 15y ago
> I care about the authoritative data model
Me too, but the truth about the world is that all inherit complexity is accompanied by incidental complexity :-/ You've got a database, you need to respect it's existence.
> mentally parse how rails reacts to the database schema
It's hilariously straightforward in 99% of cases:
For each column, a getter and setter are created. The getter directly calls read_attribute and the setter calls write_attribute. Those two methods do standard string/integer/date/etc primitive conversion. What's there to map in your head?
> Manual migrations exist, and are the default.
Right, that's the point I'm making. They should be the default. I'm also saying that I shouldn't have to write a migration AND maintain some declarations in the python file.
> it's painfully easy to create a situation where your manual migration depends on properties of your model that have since changed.
Oh, I've made this mistake. Since then, I stopped referencing my models in my migrations. I just run raw SQL (or the shorthand Ruby functions for the most common cases). As a result, my migrations are waaaay faster (batch updates rather loops, etc) and I've never had this problem since.
- awj 15y agoFYI, you can re-declare as much of the model class as you need and simply call reset_column_info as a class method before using it. The models at work have some homemade serialized attributes (don't ask), and this makes it easier to deal with that situation.