Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(coderd/database): migrate workspaces.last_used_at to timestamptz#9699

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 8 commits intomainfromcj/workspaces-last-used-at-timestamptz
Sep 18, 2023

Conversation

johnstcn
Copy link
Member

Partiallyresolves#9682 (will update users.last_seen_at in a separate PR).

@johnstcnjohnstcn self-assigned thisSep 15, 2023
@johnstcnjohnstcn marked this pull request as ready for reviewSeptember 15, 2023 14:10
Copy link
Member

@mtojekmtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

👍

ALTER TABLE ONLY workspaces
ALTER COLUMN last_used_at
SET DATA TYPE timestamp
USING last_used_at::timestamptz,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If we want to be 100% correct, this could use anAT TIME ZONE 'UTC' too because during the up migration we are changing the time (correctly) if the db time zone is non-UTC.

This demonstrates how the timestamp would be coerced into the wrong time without

woop=# create temp table testy (ts timestamp, tsz timestamptz);CREATE TABLEwoop=# insert into testy (ts, tsz) values ('0001-01-01 00:00:00+00', '0001-01-01 00:00:00+00'); select * from testy;INSERT 0 1         ts          |             tsz---------------------+------------------------------ 0001-01-01 00:00:00 | 0001-01-01 01:39:49+01:39:49(1 row)woop=# update testy set ts = tsz::timestamptz; select * from testy;UPDATE 1         ts          |             tsz---------------------+------------------------------ 0001-01-01 01:39:49 | 0001-01-01 01:39:49+01:39:49(1 row)

Whereas with the time zone change:

woop=# truncate table testy;TRUNCATE TABLEwoop=# insert into testy (ts, tsz) values ('0001-01-01 00:00:00+00', '0001-01-01 00:00:00+00'); select * from testy;INSERT 0 1         ts          |             tsz---------------------+------------------------------ 0001-01-01 00:00:00 | 0001-01-01 01:39:49+01:39:49(1 row)woop=# update testy set ts = tsz at time zone 'utc'; select * from testy;UPDATE 1         ts          |             tsz---------------------+------------------------------ 0001-01-01 00:00:00 | 0001-01-01 01:39:49+01:39:49(1 row)

johnstcn reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Updated!

@johnstcnjohnstcn merged commit9bcff30 intomainSep 18, 2023
@johnstcnjohnstcn deleted the cj/workspaces-last-used-at-timestamptz branchSeptember 18, 2023 10:07
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsSep 18, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri approved these changes

@mtojekmtojekmtojek approved these changes

Assignees

@johnstcnjohnstcn

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

bug(coderd/database): workspaces.last_used_at is missing timezone component
3 participants
@johnstcn@mafredri@mtojek

[8]ページ先頭

©2009-2025 Movatter.jp