Skip to content

Commit e84bbbf

Browse files
committed
add the SourceExampleID field to TemplateVersion
1 parent a9195bf commit e84bbbf

File tree

7 files changed

+82
-12
lines changed

7 files changed

+82
-12
lines changed

coderd/database/dump.sql

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-- We cannot alter the column type while a view depends on it, so we drop it and recreate it.
2+
DROP VIEW template_version_with_user;
3+
4+
ALTER TABLE
5+
template_versions
6+
DROP COLUMN source_example_id;
7+
8+
-- Recreate `template_version_with_user` as described in dump.sql
9+
CREATE VIEW template_version_with_user AS
10+
SELECT
11+
template_versions.id,
12+
template_versions.template_id,
13+
template_versions.organization_id,
14+
template_versions.created_at,
15+
template_versions.updated_at,
16+
template_versions.name,
17+
template_versions.readme,
18+
template_versions.job_id,
19+
template_versions.created_by,
20+
template_versions.external_auth_providers,
21+
template_versions.message,
22+
template_versions.archived,
23+
COALESCE(visible_users.avatar_url, ''::text) AS created_by_avatar_url,
24+
COALESCE(visible_users.username, ''::text) AS created_by_username
25+
FROM (template_versions
26+
LEFT JOIN visible_users ON (template_versions.created_by = visible_users.id));
27+
28+
COMMENT ON VIEW template_version_with_user IS 'Joins in the username + avatar url of the created by user.';
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-- We cannot alter the column type while a view depends on it, so we drop it and recreate it.
2+
DROP VIEW template_version_with_user;
3+
4+
ALTER TABLE
5+
template_versions
6+
ADD
7+
COLUMN source_example_id TEXT;
8+
9+
-- Recreate `template_version_with_user` as described in dump.sql
10+
CREATE VIEW template_version_with_user AS
11+
SELECT
12+
template_versions.id,
13+
template_versions.template_id,
14+
template_versions.organization_id,
15+
template_versions.created_at,
16+
template_versions.updated_at,
17+
template_versions.name,
18+
template_versions.readme,
19+
template_versions.job_id,
20+
template_versions.created_by,
21+
template_versions.external_auth_providers,
22+
template_versions.message,
23+
template_versions.archived,
24+
template_versions.source_example_id,
25+
COALESCE(visible_users.avatar_url, ''::text) AS created_by_avatar_url,
26+
COALESCE(visible_users.username, ''::text) AS created_by_username
27+
FROM (template_versions
28+
LEFT JOIN visible_users ON (template_versions.created_by = visible_users.id));
29+
30+
COMMENT ON VIEW template_version_with_user IS 'Joins in the username + avatar url of the created by user.';

coderd/database/models.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

Lines changed: 15 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)