@@ -15,6 +15,7 @@ WHERE w.id IN (
15
15
AND b .template_version_id = t .active_version_id
16
16
AND p .current_preset_id = @preset_id::uuid
17
17
AND p .ready
18
+ AND NOT t .deleted
18
19
LIMIT 1 FOR UPDATE OF p SKIP LOCKED -- Ensure that a concurrent request will not select the same prebuild.
19
20
)
20
21
RETURNING w .id , w .name ;
@@ -40,6 +41,7 @@ FROM templates t
40
41
INNER JOIN template_version_presets tvp ON tvp .template_version_id = tv .id
41
42
INNER JOIN organizations o ON o .id = t .organization_id
42
43
WHERE tvp .desired_instances IS NOT NULL -- Consider only presets that have a prebuild configuration.
44
+ AND NOT t .deleted
43
45
AND (t .id = sqlc .narg (' template_id' )::uuid OR sqlc .narg (' template_id' ) IS NULL );
44
46
45
47
-- name: GetRunningPrebuiltWorkspaces :many
@@ -70,6 +72,7 @@ FROM workspace_latest_builds wlb
70
72
-- prebuilds that are still building.
71
73
INNER JOIN templates t ON t .active_version_id = wlb .template_version_id
72
74
WHERE wlb .job_status IN (' pending' ::provisioner_job_status, ' running' ::provisioner_job_status)
75
+ AND NOT t .deleted
73
76
GROUP BY t .id , wpb .template_version_id , wpb .transition , wlb .template_version_preset_id ;
74
77
75
78
-- GetPresetsBackoff groups workspace builds by preset ID.
@@ -98,6 +101,7 @@ WITH filtered_builds AS (
98
101
WHERE tvp .desired_instances IS NOT NULL -- Consider only presets that have a prebuild configuration.
99
102
AND wlb .transition = ' start' ::workspace_transition
100
103
AND w .owner_id = ' c42fdf75-3097-471c-8c33-fb52454d81c0'
104
+ AND NOT t .deleted
101
105
),
102
106
time_sorted_builds AS (
103
107
-- Group builds by preset, then sort each group by created_at.
0 commit comments