Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5786e81

Browse files
committed
add migration
1 parent 6ef1bee commit 5786e81

File tree

5 files changed

+60
-5
lines changed

5 files changed

+60
-5
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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
BEGIN;
2+
3+
ALTER TABLE templates DROP COLUMN require_promoted_version;
4+
5+
-- Update the template_with_users view;
6+
DROP VIEW template_with_users;
7+
-- If you need to update this view, put 'DROP VIEW template_with_users;' before this.
8+
CREATE VIEW
9+
template_with_users
10+
AS
11+
SELECT
12+
templates.*,
13+
coalesce(visible_users.avatar_url, '') AS created_by_avatar_url,
14+
coalesce(visible_users.username, '') AS created_by_username
15+
FROM
16+
templates
17+
LEFT JOIN
18+
visible_users
19+
ON
20+
templates.created_by = visible_users.id;
21+
22+
COMMENT ON VIEW template_with_users IS 'Joins in the username + avatar url of the created by user.';
23+
24+
COMMIT;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
BEGIN;
2+
3+
DROP VIEW template_with_users;
4+
5+
ALTER TABLE templates ADD COLUMN require_promoted_version boolean NOT NULL DEFAULT 'f';
6+
7+
CREATE VIEW
8+
template_with_users
9+
AS
10+
SELECT
11+
templates.*,
12+
coalesce(visible_users.avatar_url, '') AS created_by_avatar_url,
13+
coalesce(visible_users.username, '') AS created_by_username
14+
FROM
15+
templates
16+
LEFT JOIN
17+
visible_users
18+
ON
19+
templates.created_by = visible_users.id;
20+
21+
COMMENT ON VIEW template_with_users IS 'Joins in the username + avatar url of the created by user.';
22+
23+
COMMIT;

coderd/database/models.go

Lines changed: 2 additions & 0 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: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)