You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To enforce consistent timestamps between databases and service instances, we want to store all timestamps in UTC. However it is not possible to enforce UTC for UpdatedAt because pop will overwrite the value with time.Now() which includes the local time zone. In contrast, CreatedAt is only set to time.Now() when it is the zero value.
Proposals
There are a view ways I can think of we can allow this kind of customization of time stamps.
Allow setting the nowFunc. This will enable globally defining the behavior.
Customizing model based. Add an interface a model can implement to touchUpdatedAt and touchCreatedAt, something like
typeUpdatedAtSetterinterface{
TouchUpdatedAt()
}
Both of above options.
I'm happy to implement this if you tell me the approach you like. I personally would prefer setting the nowFunc globally.
The text was updated successfully, but these errors were encountered:
Description
To enforce consistent timestamps between databases and service instances, we want to store all timestamps in UTC. However it is not possible to enforce UTC for
UpdatedAt
because pop will overwrite the value withtime.Now()
which includes the local time zone. In contrast,CreatedAt
is only set totime.Now()
when it is the zero value.Proposals
There are a view ways I can think of we can allow this kind of customization of time stamps.
Allow setting the
nowFunc
. This will enable globally defining the behavior.Customizing model based. Add an interface a model can implement to
touchUpdatedAt
andtouchCreatedAt
, something likeI'm happy to implement this if you tell me the approach you like. I personally would prefer setting the
nowFunc
globally.The text was updated successfully, but these errors were encountered: