Skip to content

Commit 6e6fbc3

Browse files
committed
migration bump
1 parent 9200779 commit 6e6fbc3

4 files changed

+28
-0
lines changed

coderd/database/migrations/000160_delete_template_versions.down.sql

Whitespace-only changes.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
BEGIN;
2+
3+
-- The view will be rebuilt with the new column
4+
DROP VIEW template_version_with_user;
5+
6+
ALTER TABLE template_versions
7+
DROP COLUMN deleted;
8+
9+
-- Restore the old version of the template_version_with_user view.
10+
CREATE VIEW
11+
template_version_with_user
12+
AS
13+
SELECT
14+
template_versions.*,
15+
coalesce(visible_users.avatar_url, '') AS created_by_avatar_url,
16+
coalesce(visible_users.username, '') AS created_by_username
17+
FROM
18+
template_versions
19+
LEFT JOIN
20+
visible_users
21+
ON
22+
template_versions.created_by = visible_users.id;
23+
24+
COMMENT ON VIEW template_version_with_user IS 'Joins in the username + avatar url of the created by user.';
25+
26+
COMMIT;

coderd/database/queries/templateversions.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ FROM
180180
-- Also never delete the active template version
181181
AND active_version_id != template_versions.id
182182
AND CASE
183+
-- Optionally, only prune versions that match a given
184+
-- job status like 'failed'.
183185
WHEN @job_status != '' THEN
184186
provisioner_jobs.job_status = @job_status
185187
ELSE

0 commit comments

Comments
 (0)