|
1 |
| --- Recreate `template_version_with_user` as described in dump.sql |
2 | 1 | DROP VIEW template_version_with_user;
|
3 | 2 |
|
4 |
| -CREATE VIEW template_version_with_user AS |
5 |
| -SELECT |
6 |
| - template_versions.id, |
7 |
| - template_versions.template_id, |
8 |
| - template_versions.organization_id, |
9 |
| - template_versions.created_at, |
10 |
| - template_versions.updated_at, |
11 |
| - template_versions.name, |
12 |
| - template_versions.readme, |
13 |
| - template_versions.job_id, |
14 |
| - template_versions.created_by, |
15 |
| - template_versions.external_auth_providers, |
16 |
| - template_versions.message, |
17 |
| - template_versions.archived, |
18 |
| - template_versions.source_example_id, |
19 |
| - COALESCE( |
20 |
| - visible_users.avatar_url, |
21 |
| - ''::text |
22 |
| - ) AS created_by_avatar_url, |
23 |
| - COALESCE( |
24 |
| - visible_users.username, |
25 |
| - ''::text |
26 |
| - ) AS created_by_username |
27 |
| -FROM ( |
28 |
| - template_versions |
29 |
| - LEFT JOIN visible_users ON ( |
30 |
| - template_versions.created_by = visible_users.id |
31 |
| - ) |
32 |
| - ); |
| 3 | +DROP VIEW workspace_build_with_user; |
33 | 4 |
|
34 |
| -COMMENT ON VIEW template_version_with_user IS 'Joins in the username + avatar url of the created by user.'; |
| 5 | +DROP VIEW template_with_names; |
| 6 | + |
| 7 | +DROP VIEW workspaces_expanded; |
| 8 | + |
| 9 | +DROP VIEW visible_users; |
| 10 | + |
| 11 | +-- Recreate `visible_users` as described in dump.sql |
| 12 | + |
| 13 | +CREATE VIEW visible_users AS |
| 14 | +SELECT users.id, users.username, users.avatar_url |
| 15 | +FROM users; |
| 16 | + |
| 17 | +COMMENT ON VIEW visible_users IS 'Visible fields of users are allowed to be joined with other tables for including context of other resources.'; |
35 | 18 |
|
36 | 19 | -- Recreate `workspace_build_with_user` as described in dump.sql
|
37 |
| -DROP VIEW workspace_build_with_user; |
38 | 20 |
|
39 | 21 | CREATE VIEW workspace_build_with_user AS
|
40 | 22 | SELECT
|
@@ -72,64 +54,7 @@ FROM (
|
72 | 54 |
|
73 | 55 | COMMENT ON VIEW workspace_build_with_user IS 'Joins in the username + avatar url of the initiated by user.';
|
74 | 56 |
|
75 |
| --- Recreate `workspaces_expanded` as described in dump.sql |
76 |
| -DROP VIEW workspaces_expanded; |
77 |
| - |
78 |
| -CREATE VIEW workspaces_expanded AS |
79 |
| -SELECT |
80 |
| - workspaces.id, |
81 |
| - workspaces.created_at, |
82 |
| - workspaces.updated_at, |
83 |
| - workspaces.owner_id, |
84 |
| - workspaces.organization_id, |
85 |
| - workspaces.template_id, |
86 |
| - workspaces.deleted, |
87 |
| - workspaces.name, |
88 |
| - workspaces.autostart_schedule, |
89 |
| - workspaces.ttl, |
90 |
| - workspaces.last_used_at, |
91 |
| - workspaces.dormant_at, |
92 |
| - workspaces.deleting_at, |
93 |
| - workspaces.automatic_updates, |
94 |
| - workspaces.favorite, |
95 |
| - workspaces.next_start_at, |
96 |
| - visible_users.avatar_url AS owner_avatar_url, |
97 |
| - visible_users.username AS owner_username, |
98 |
| - organizations.name AS organization_name, |
99 |
| - organizations.display_name AS organization_display_name, |
100 |
| - organizations.icon AS organization_icon, |
101 |
| - organizations.description AS organization_description, |
102 |
| - templates.name AS template_name, |
103 |
| - templates.display_name AS template_display_name, |
104 |
| - templates.icon AS template_icon, |
105 |
| - templates.description AS template_description |
106 |
| -FROM ( |
107 |
| - ( |
108 |
| - ( |
109 |
| - workspaces |
110 |
| - JOIN visible_users ON ( |
111 |
| - ( |
112 |
| - workspaces.owner_id = visible_users.id |
113 |
| - ) |
114 |
| - ) |
115 |
| - ) |
116 |
| - JOIN organizations ON ( |
117 |
| - ( |
118 |
| - workspaces.organization_id = organizations.id |
119 |
| - ) |
120 |
| - ) |
121 |
| - ) |
122 |
| - JOIN templates ON ( |
123 |
| - ( |
124 |
| - workspaces.template_id = templates.id |
125 |
| - ) |
126 |
| - ) |
127 |
| - ); |
128 |
| - |
129 |
| -COMMENT ON VIEW workspaces_expanded IS 'Joins in the display name information such as username, avatar, and organization name.'; |
130 |
| - |
131 | 57 | -- Recreate `template_with_names` as described in dump.sql
|
132 |
| -DROP VIEW template_with_names; |
133 | 58 |
|
134 | 59 | CREATE VIEW template_with_names AS
|
135 | 60 | SELECT
|
@@ -195,7 +120,6 @@ FROM (
|
195 | 120 | COMMENT ON VIEW template_with_names IS 'Joins in the display name information such as username, avatar, and organization name.';
|
196 | 121 |
|
197 | 122 | -- Recreate `template_version_with_user` as described in dump.sql
|
198 |
| -DROP VIEW template_version_with_user; |
199 | 123 |
|
200 | 124 | CREATE VIEW template_version_with_user AS
|
201 | 125 | SELECT
|
@@ -223,19 +147,63 @@ SELECT
|
223 | 147 | FROM (
|
224 | 148 | template_versions
|
225 | 149 | LEFT JOIN visible_users ON (
|
226 |
| - ( |
227 |
| - template_versions.created_by = visible_users.id |
228 |
| - ) |
| 150 | + template_versions.created_by = visible_users.id |
229 | 151 | )
|
230 | 152 | );
|
231 | 153 |
|
232 | 154 | COMMENT ON VIEW template_version_with_user IS 'Joins in the username + avatar url of the created by user.';
|
233 | 155 |
|
234 |
| --- Recreate `visible_users` as described in dump.sql |
235 |
| -DROP VIEW visible_users; |
| 156 | +-- Recreate `workspaces_expanded` as described in dump.sql |
236 | 157 |
|
237 |
| -CREATE VIEW visible_users AS |
238 |
| -SELECT users.id, users.username, users.avatar_url |
239 |
| -FROM users; |
| 158 | +CREATE VIEW workspaces_expanded AS |
| 159 | +SELECT |
| 160 | + workspaces.id, |
| 161 | + workspaces.created_at, |
| 162 | + workspaces.updated_at, |
| 163 | + workspaces.owner_id, |
| 164 | + workspaces.organization_id, |
| 165 | + workspaces.template_id, |
| 166 | + workspaces.deleted, |
| 167 | + workspaces.name, |
| 168 | + workspaces.autostart_schedule, |
| 169 | + workspaces.ttl, |
| 170 | + workspaces.last_used_at, |
| 171 | + workspaces.dormant_at, |
| 172 | + workspaces.deleting_at, |
| 173 | + workspaces.automatic_updates, |
| 174 | + workspaces.favorite, |
| 175 | + workspaces.next_start_at, |
| 176 | + visible_users.avatar_url AS owner_avatar_url, |
| 177 | + visible_users.username AS owner_username, |
| 178 | + organizations.name AS organization_name, |
| 179 | + organizations.display_name AS organization_display_name, |
| 180 | + organizations.icon AS organization_icon, |
| 181 | + organizations.description AS organization_description, |
| 182 | + templates.name AS template_name, |
| 183 | + templates.display_name AS template_display_name, |
| 184 | + templates.icon AS template_icon, |
| 185 | + templates.description AS template_description |
| 186 | +FROM ( |
| 187 | + ( |
| 188 | + ( |
| 189 | + workspaces |
| 190 | + JOIN visible_users ON ( |
| 191 | + ( |
| 192 | + workspaces.owner_id = visible_users.id |
| 193 | + ) |
| 194 | + ) |
| 195 | + ) |
| 196 | + JOIN organizations ON ( |
| 197 | + ( |
| 198 | + workspaces.organization_id = organizations.id |
| 199 | + ) |
| 200 | + ) |
| 201 | + ) |
| 202 | + JOIN templates ON ( |
| 203 | + ( |
| 204 | + workspaces.template_id = templates.id |
| 205 | + ) |
| 206 | + ) |
| 207 | + ); |
240 | 208 |
|
241 |
| -COMMENT ON VIEW visible_users IS 'Visible fields of users are allowed to be joined with other tables for including context of other resources.'; |
| 209 | +COMMENT ON VIEW workspaces_expanded IS 'Joins in the display name information such as username, avatar, and organization name.'; |
0 commit comments