Preserve timestamps when loading the database from serialized data

Review Request #21 — Created May 21, 2007 and submitted — Latest diff uploaded

chipx86
Review Board SVN (deprecated)
trunk
reviewboard
Due to our usage of auto_now and auto_now_add in the DateTimeFields, any load of a DB dump would cause all timestamps to be reset to datetime.now(). The Django people recognize this as a problem and are planning to phase out these parameters and add new fields for making this work better when serialized. For now, though, instead of auto_now, we provide a ModificationTimestampField, which sets now() only when the model is first being saved to the database or when the value of the field is None.

auto_now_add has been replaced with default=datetime.now, which is what's recommended and being used in Django. It provides the same functionality as auto_now_add=True, but allows the value to be replaced (making it properly load from serialized dumps).
Created some new review requests. Saw the correct timestamps for creation.

Updated the review requests and saw that the last_updated field was set correctly.

Dumped the database and reloaded. Saw that the timestamps were preserved.

Did a little dance. Didn't make a little love, though.
Loading...