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:
Steven Masley
2023-07-25 09:14:38 -04:00
committed by GitHub
parent fbb2a6a434
commit de1a7a9210
39 changed files with 819 additions and 717 deletions
+12 -12
View File
@@ -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