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

Standardize datetime configuration on the backend #1647

Open
5 tasks
ianliuwk1019 opened this issue Nov 5, 2024 · 0 comments
Open
5 tasks

Standardize datetime configuration on the backend #1647

ianliuwk1019 opened this issue Nov 5, 2024 · 0 comments

Comments

@ianliuwk1019
Copy link
Collaborator

ianliuwk1019 commented Nov 5, 2024

Several existing behaviors related to backend table models timestamp columns were observed:

  • Tables' "update_date" (model.py) is empty during programmatically INSERT. We would like to have initial values as "create_date" during insert.
  • Previously we didn't notice the value inserted into timestamp column using datetime.datetime.now() (in model.py) is a fixed value. This means the timestamp value is determined during model is loaded, and all the records inserted with this datetime.datetime.now() (in model.py) after backend model is loaded will have the same values and not the moment the records are inserted. We will need to fix this.
  • Most of the timestamp columns are timestamp WITH TIME ZON, but some tables have timestamp WITHOUT TIME ZON. We need to make them consistent.

Screenshots
image
image

Acceptance Criteria

  • Discuss if needs to have or fix "update_date" in model.py to have value during initial insert.
  • Fix timestamp columns for all tables to use Sqlalchemy func.utcnow() than datetime.datetime.now().
  • Use timestamp WITH TIME ZON for all timestamp columns.
  • Make sure all existing tests still pass.
  • Document and close previous sqlacodegen tickets (on generating the model.py)

Additional context

  • May need to discuss why we need to have value for the "update_date" during initial insert (so it is not empty when record is created), or if this is a good practice; and how to deal with current production empty "update_date" if we decide to have value in "update_date" initial during insert.

Related issue #1695 created to split off some refactoring of model.py

@gormless87 gormless87 changed the title Fix backend model update_date without initial value during insert Standardize datetime configuration on the backend Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant