Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable customizing CreatedAt and UpdatedAt touching #591

Closed
zepatrik opened this issue Sep 15, 2020 · 0 comments
Closed

Enable customizing CreatedAt and UpdatedAt touching #591

zepatrik opened this issue Sep 15, 2020 · 0 comments

Comments

@zepatrik
Copy link
Contributor

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 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.

  1. Allow setting the nowFunc. This will enable globally defining the behavior.

  2. Customizing model based. Add an interface a model can implement to touchUpdatedAt and touchCreatedAt, something like

type UpdatedAtSetter interface{
  TouchUpdatedAt()
}
  1. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant