website
website copied to clipboard
Consequences of disabling timestamps
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 ?
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
Thank you very much for the quick answer ! 😄