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

Discussion: Default values for database fields of type "datetime" #86

Open
muratpurc opened this issue Nov 29, 2019 · 3 comments
Open
Labels
help wanted Extra attention is needed question Further information is requested
Milestone

Comments

@muratpurc
Copy link
Collaborator

With the issue #22, we have fixed posible errors with dates in database fields having the "NOT NULL" constraint and "0000-00-00 00:00:00" as a default value. Almost all occurrences "0000-00-00 00:00:00" has been replaced with CURRENT_TIMESTAMP.

But I see a problem in some database fields by using CURRENT_TIMESTAMP, for example:

  • con_user.last_pw_request: The value of it will be used for time limit comparsion, see setting (type = 'pw_request', name = 'outdated_threshold'). A new registered user has to wait a certain amount of time before requesting a new password.
  • con_art_lang.published: Usually, the published date will be set, if an article goes online. Setting it CURRENT_TIMESTAMP to is wrong and could be misleading.
  • Other fields might be also affected by the CURRENT_TIMESTAMP

We should think about removing the "NOT NULL" constraint for some fields for those where we need this constaint, we could use a datetime in the past, e. g. "1970-01-01 00:00:00".

Any other ideas or suggestions are welcome?

@muratpurc muratpurc added help wanted Extra attention is needed question Further information is requested labels Nov 29, 2019
@muratpurc muratpurc changed the title Default values for database fields of type "datetime" Discussion: Default values for database fields of type "datetime" Nov 29, 2019
@muratpurc
Copy link
Collaborator Author

muratpurc commented Dec 2, 2019

Table con_frontendusers has the fields valid_from and valid_to, both without the NOT NULL constraint. We should use this also for table con_user. It would be consistent, we don't have to think about what date to use instead of '0000-00-00 00:00:00' or CURRENT_TIMESTAMP, and I see also no backwards compatibility issues.

@muratpurc
Copy link
Collaborator Author

Please follow the discussion in CONTENIDO forum:
https://forum.contenido.org/viewtopic.php?f=115&t=43800

@muratpurc
Copy link
Collaborator Author

muratpurc commented Dec 7, 2019

The result of the disussion im forum is as follows:

We don't need the "NOT NULL" constraint for the database fields, therefore we can remove it from almost all database fields. Database fields of type datetime should have a NULL value and this will make the usage of CURRENT_TIMESTAMP obsolete. This solution should work for almost all cases. I'll create an issue for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
Status: To do
Development

No branches or pull requests

1 participant