feat: add template max_ttl (#6114)

Co-authored-by: Bruno Quaresma <bruno@coder.com>
This commit is contained in:
Dean Sheather
2023-03-07 14:14:58 +00:00
committed by GitHub
co-authored by Bruno Quaresma
parent 248c53d68d
commit 66a6b590a1
71 changed files with 2090 additions and 398 deletions
+14
View File
@@ -316,3 +316,17 @@ SET
last_used_at = $2
WHERE
id = $1;
-- name: UpdateWorkspaceTTLToBeWithinTemplateMax :exec
UPDATE
workspaces
SET
ttl = LEAST(ttl, @template_max_ttl::bigint)
WHERE
template_id = @template_id
-- LEAST() does not pick NULL, so filter it out as we don't want to set a
-- TTL on the workspace if it's unset.
--
-- During build time, the template max TTL will still be used if the
-- workspace TTL is NULL.
AND ttl IS NOT NULL;