Set entity columns to be 'timestamp with time zone' to avoid TZ-related test failures #4720
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The Postgres
TIMESTAMP
type records a date and time irrespective of (ignoring) timezone. This aligns with the SQL standard, but they also have aTIMESTAMP WITH TIME ZONE
(akaTIMESTAMPTZ
) which is timezone aware. It turns out thatlib/pq
(at least) storestime.Time
values into the database using local time forTIMESTAMP
columns, but reads back the columns in the zero-timezone. In PDT (UTC+7), this results in reading back times which are 7 hours later than when they were stored. This mostly doesn't bother our code and tests at the moment, but it does break tests ininternal/entities/properties/service
, which useupdated_at
as a cache validation mechanism.This PR migrates the
TIMESTAMP
fields added in000090
toTIMESTAMPTZ
in a way which should avoid table locks, and which causes the above tests to pass on my machine where they failed otherwise. Note that the tests would only fail for people in timezones west of GMT, so this probably wouldn't affect affect folks in CET or easterly.Change Type
Mark the type of change your PR introduces:
Testing
Unit tests pass for my on my local machine, where they failed before.
Review Checklist: