You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: coderd/database/queries/workspaces.sql
+20-10Lines changed: 20 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -476,20 +476,30 @@ WHERE
476
476
477
477
-- name: UpdateWorkspaceDormantDeletingAt :one
478
478
UPDATE
479
-
workspaces
479
+
workspaces
480
480
SET
481
-
dormant_at = $2,
482
-
-- When a workspace is active we want to update the last_used_at to avoid the workspace going
481
+
dormant_at = $2,
482
+
-- When a workspace is active we want to update the last_used_at to avoid the workspace going
483
483
-- immediately dormant. If we're transition the workspace to dormant then we leave it alone.
484
-
last_used_at = CASE WHEN $2::timestamptz IS NULL THEN now() at time zone 'utc' ELSE last_used_at END,
485
-
-- If dormant_at is null (meaning active) or the template-defined time_til_dormant_autodelete is 0 we should set
486
-
-- deleting_at to NULL else set it to the dormant_at + time_til_dormant_autodelete duration.
487
-
deleting_at = CASE WHEN $2::timestamptz IS NULLORtemplates.time_til_dormant_autodelete=0 THEN NULL ELSE $2::timestamptz+ INTERVAL '1 milliseconds'*templates.time_til_dormant_autodelete/1000000 END
484
+
last_used_at = CASE WHEN $2::timestamptz IS NULL THEN
485
+
now() at time zone 'utc'
486
+
ELSE
487
+
last_used_at
488
+
END,
489
+
-- If dormant_at is null (meaning active) or the template-defined time_til_dormant_autodelete is 0 we should set
490
+
-- deleting_at to NULL else set it to the dormant_at + time_til_dormant_autodelete duration.
491
+
deleting_at = CASE WHEN $2::timestamptz IS NULLORtemplates.time_til_dormant_autodelete=0 THEN
0 commit comments