Ruby on Rails' ORM has a t.timestamps handler. It adds (and fills and updates) created_at/updated_at rows in your tables.
But I can think of some reasons when not to use timestamps:
- They clutter your database with information th开发者_JAVA百科at might never be used.
- They take up resources when updating/inserting items.
Are there good rules of thumb on when to include updated_at and created_at columns and when to leave them out?
Are my reasons not to use them valid? Or can that be ignored and should I simply go with "just add them, regardless, you never know when you might need them"?
Youre absolutely right. If you dont need them, dont use them.
Well we use them in our scenario - several apps talk to each other using REST. It gives us possibility to compare two resources just by comparing the timestamps. We dont need to fetch whole resource and compare by attribute basic. This is my case when I need timestamps.
I keep them turned off when I dont need them.
精彩评论