mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: join user information to workspace_build and template_version (#8625)
* include minimial user on template version and build * Add unit test to ensure join is superset
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
template_versions
|
||||
template_version_with_user AS template_versions
|
||||
WHERE
|
||||
template_id = @template_id :: uuid
|
||||
AND CASE
|
||||
@@ -36,18 +36,18 @@ LIMIT
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
template_versions
|
||||
template_version_with_user AS template_versions
|
||||
WHERE
|
||||
job_id = $1;
|
||||
|
||||
-- name: GetTemplateVersionsCreatedAfter :many
|
||||
SELECT * FROM template_versions WHERE created_at > $1;
|
||||
SELECT * FROM template_version_with_user AS template_versions WHERE created_at > $1;
|
||||
|
||||
-- name: GetTemplateVersionByTemplateIDAndName :one
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
template_versions
|
||||
template_version_with_user AS template_versions
|
||||
WHERE
|
||||
template_id = $1
|
||||
AND "name" = $2;
|
||||
@@ -56,7 +56,7 @@ WHERE
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
template_versions
|
||||
template_version_with_user AS template_versions
|
||||
WHERE
|
||||
id = $1;
|
||||
|
||||
@@ -64,11 +64,11 @@ WHERE
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
template_versions
|
||||
template_version_with_user AS template_versions
|
||||
WHERE
|
||||
id = ANY(@ids :: uuid [ ]);
|
||||
|
||||
-- name: InsertTemplateVersion :one
|
||||
-- name: InsertTemplateVersion :exec
|
||||
INSERT INTO
|
||||
template_versions (
|
||||
id,
|
||||
@@ -83,9 +83,9 @@ INSERT INTO
|
||||
created_by
|
||||
)
|
||||
VALUES
|
||||
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING *;
|
||||
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);
|
||||
|
||||
-- name: UpdateTemplateVersionByID :one
|
||||
-- name: UpdateTemplateVersionByID :exec
|
||||
UPDATE
|
||||
template_versions
|
||||
SET
|
||||
@@ -94,7 +94,7 @@ SET
|
||||
name = $4,
|
||||
message = $5
|
||||
WHERE
|
||||
id = $1 RETURNING *;
|
||||
id = $1;
|
||||
|
||||
-- name: UpdateTemplateVersionDescriptionByJobID :exec
|
||||
UPDATE
|
||||
@@ -118,11 +118,11 @@ WHERE
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
template_versions
|
||||
template_version_with_user AS template_versions
|
||||
WHERE
|
||||
created_at < (
|
||||
SELECT created_at
|
||||
FROM template_versions AS tv
|
||||
FROM template_version_with_user AS tv
|
||||
WHERE tv.organization_id = $1 AND tv.name = $2 AND tv.template_id = $3
|
||||
)
|
||||
AND organization_id = $1
|
||||
|
||||
Reference in New Issue
Block a user