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

Consequences of disabling timestamps #122

Open
Hackatosh opened this issue Apr 21, 2022 · 2 comments
Open

Consequences of disabling timestamps #122

Hackatosh opened this issue Apr 21, 2022 · 2 comments

Comments

@Hackatosh
Copy link

Issue Creation Checklist

[X] I have read the contribution guidelines

Issue Description

What was unclear/insufficient/not covered in the documentation

The consequences of disabling the timestamps (createdAt / updatedAt) are not very clear in the documentation : https://sequelize.org/docs/v6/core-concepts/model-basics/

If possible: Provide some suggestion on how we can enhance the docs

Make clear what is the impact of disabling the timestamps. Are they used internally by Sequelize for any purpose ? Or are we completely free to disable them ?

Additional context

Hello ! I have a use case where I need to track the last modification time of every row of a table, which can be modified through Sequelize and through SQL queries executed directly on the DB. I'd like to store this time in the updated_at column. In order for this time to be accurate, I'd like to disable Sequelize's automatic update on updated_at column and add a SQL trigger, but I am not sure of the impact of this action.

Also, if I use those parameters for the Model init :

{
  sequelize,
  timestamps: true,
  updatedAt: false
}

Will the column updated still be present but without the automatic update from Sequelize ? Or am I mistaken ?

@ephys ephys transferred this issue from sequelize/sequelize Apr 21, 2022
@ephys
Copy link
Member

ephys commented Apr 21, 2022

createdAt and updatedAt are not used for anything by sequelize itself. It's safe to disable them, and add your own.

deletedAt is necessary if the model is paranoid

@Hackatosh
Copy link
Author

Thank you very much for the quick answer ! 😄

@ephys ephys removed the type: docs label Apr 11, 2024
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

2 participants