feat(coderd/database/dbpurge): add retention for connection logs (#21022)

Add `DeleteOldConnectionLogs` query and integrate it into the `dbpurge`
routine. Retention is controlled by `--retention-connection-logs` flag.
Disabled (0) by default.

Depends on #21021
Updates #20743
This commit is contained in:
Mathias Fredriksson
2025-12-02 14:17:52 +00:00
committed by GitHub
parent 56e7858570
commit 9ebcca5b0d
9 changed files with 213 additions and 2 deletions
@@ -239,6 +239,18 @@ WHERE
-- @authorize_filter
;
-- name: DeleteOldConnectionLogs :execrows
WITH old_logs AS (
SELECT id
FROM connection_logs
WHERE connect_time < @before_time::timestamp with time zone
ORDER BY connect_time ASC
LIMIT @limit_count
)
DELETE FROM connection_logs
USING old_logs
WHERE connection_logs.id = old_logs.id;
-- name: UpsertConnectionLog :one
INSERT INTO connection_logs (
id,