Make updated date non-nullable
A question that's been bugging me a while about pubsweet's BaseModel: Why does updated
allow null values rather than defaulting to the current timestamp? All Kotahi's migrations create the created
and updated
columns like this:
created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT current_timestamp,
updated TIMESTAMP WITH TIME ZONE,
It seems like the reason might be that we want to be able to tell if a row has never been updated since its creation, but is this something that's actually used? And couldn't we equally tell this by comparing created
and updated
dates? The downside of doing it this way is that we have to account for possible null values in any logic we apply to updated
, such as ordering by or displaying the updated date. And conceptually, the initial creation of the row could be considered an update, depending on your definition.
I don't consider this a major problem, just something that could be a little tidier -- and it tripped up one of the devs recently.