fix(coderd/database): remove column updated_at from provisioner_daemons table (#11108)

This commit is contained in:
Cian Johnston
2023-12-12 11:19:28 +00:00
committed by GitHub
parent 197cd935cf
commit b02796655e
17 changed files with 21 additions and 39 deletions
@@ -12,7 +12,7 @@ INSERT INTO
"name",
provisioners,
tags,
updated_at
last_seen_at
)
VALUES
($1, $2, $3, $4, $5, $6) RETURNING *;
@@ -20,9 +20,9 @@ VALUES
-- name: DeleteOldProvisionerDaemons :exec
-- Delete provisioner daemons that have been created at least a week ago
-- and have not connected to coderd since a week.
-- A provisioner daemon with "zeroed" updated_at column indicates possible
-- A provisioner daemon with "zeroed" last_seen_at column indicates possible
-- connectivity issues (no provisioner daemon activity since registration).
DELETE FROM provisioner_daemons WHERE (
(created_at < (NOW() - INTERVAL '7 days') AND updated_at IS NULL) OR
(updated_at IS NOT NULL AND updated_at < (NOW() - INTERVAL '7 days'))
(created_at < (NOW() - INTERVAL '7 days') AND last_seen_at IS NULL) OR
(last_seen_at IS NOT NULL AND last_seen_at < (NOW() - INTERVAL '7 days'))
);