8000 refactor: rename sql table · coder/coder@ee1f16a · GitHub
[go: up one dir, main page]

Skip to content

Commit ee1f16a

Browse files
refactor: rename sql table
1 parent ccc309e commit ee1f16a

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed

coderd/database/dump.sql

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

coderd/database/migrations/000302_prebuilds.up.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-- workspace_latest_build contains latest build for every workspace
2-
CREATE VIEW workspace_latest_build AS
1+
-- workspace_latest_builds contains latest build for every workspace
2+
CREATE VIEW workspace_latest_builds AS
33
SELECT DISTINCT ON (workspace_id) *
44
FROM workspace_builds
55
ORDER BY workspace_id, build_number DESC;
@@ -18,12 +18,12 @@ WITH
1818
--
1919
-- See https://github.com/coder/internal/issues/398
2020
latest_prebuild_builds AS (SELECT *
21-
FROM workspace_latest_build
21+
FROM workspace_latest_builds
2222
WHERE template_version_preset_id IS NOT NULL),
2323
-- All workspace agents belonging to the workspaces owned by the "prebuilds" user.
2424
workspace_agents AS (SELECT w.id AS workspace_id, wa.id AS agent_id, wa.lifecycle_state, wa.ready_at
2525
FROM workspaces w
26-
INNER JOIN workspace_latest_build wlb ON wlb.workspace_id = w.id
26+
INNER JOIN workspace_latest_builds wlb ON wlb.workspace_id = w.id
2727
INNER JOIN workspace_resources wr ON wr.job_id = wlb.job_id
2828
INNER JOIN workspace_agents wa ON wa.resource_id = wr.id
2929
WHERE w.owner_id = 'c42fdf75-3097-471c-8c33-fb52454d81c0' -- The system user responsible for prebuilds.

coderd/database/queries.sql.go

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

coderd/database/queries/prebuilds.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SELECT p.id AS workspace_id,
2929
ELSE FALSE END AS ready,
3030
p.created_at
3131
FROM workspace_prebuilds p
32-
INNER JOIN workspace_latest_build b ON b.workspace_id = p.id
32+
INNER JOIN workspace_latest_builds b ON b.workspace_id = p.id
3333
INNER JOIN provisioner_jobs pj ON b.job_id = pj.id
3434
INNER JOIN templates t ON p.template_id = t.id
3535
LEFT JOIN template_version_presets tvp_curr
@@ -39,7 +39,7 @@ WHERE (b.transition = 'start'::workspace_transition
3939

4040
-- name: GetPrebuildsInProgress :many
4141
SELECT t.id AS template_id, wpb.template_version_id, wpb.transition, COUNT(wpb.transition)::int AS count
42-
FROM workspace_latest_build wlb
42+
FROM workspace_latest_builds wlb
4343
INNER JOIN provisioner_jobs pj ON wlb.job_id = pj.id
4444
INNER JOIN workspace_prebuild_builds wpb ON wpb.id = wlb.id
4545
INNER JOIN templates t ON t.active_version_id = wlb.template_version_id
@@ -66,7 +66,7 @@ WITH filtered_builds AS (
6666
-- Only select builds which are for prebuild creations
6767
SELECT wlb.*, tvp.id AS preset_id, pj.job_status, tvp.desired_instances
6868
FROM template_version_presets tvp
69-
JOIN workspace_latest_build wlb ON wlb.template_version_preset_id = tvp.id
69+
JOIN workspace_latest_builds wlb ON wlb.template_version_preset_id = tvp.id
7070
JOIN provisioner_jobs pj ON wlb.job_id = pj.id
7171
JOIN template_versions tv ON wlb.template_version_id = tv.id
7272
JOIN templates t ON tv.template_id = t.id AND t.active_version_id = tv.id
@@ -104,7 +104,7 @@ SET owner_id = @new_user_id::uuid,
104104
updated_at = NOW()
105105
WHERE w.id IN (SELECT p.id
106106
FROM workspace_prebuilds p
107-
INNER JOIN workspace_latest_build b ON b.workspace_id = p.id
107+
INNER JOIN workspace_latest_builds b ON b.workspace_id = p.id
108108
INNER JOIN provisioner_jobs pj ON b.job_id = pj.id
109109
INNER JOIN templates t ON p.template_id = t.id
110110
WHERE (b.transition = 'start'::workspace_transition

0 commit comments

Comments
 (0)
0