Files
coder/coderd/database/queries/templates.sql
T

69 lines
905 B
SQL
Raw Normal View History

2022-04-06 12:42:40 -05:00
-- name: GetTemplateByID :one
SELECT
*
FROM
2022-04-06 12:42:40 -05:00
templates
WHERE
id = $1
LIMIT
1;
2022-04-06 12:42:40 -05:00
-- name: GetTemplatesByIDs :many
SELECT
*
FROM
2022-04-06 12:42:40 -05:00
templates
WHERE
id = ANY(@ids :: uuid [ ]);
2022-04-06 12:42:40 -05:00
-- name: GetTemplateByOrganizationAndName :one
SELECT
*
FROM
2022-04-06 12:42:40 -05:00
templates
WHERE
organization_id = @organization_id
AND deleted = @deleted
AND LOWER("name") = LOWER(@name)
LIMIT
1;
2022-04-06 12:42:40 -05:00
-- name: GetTemplatesByOrganization :many
SELECT
*
FROM
2022-04-06 12:42:40 -05:00
templates
WHERE
organization_id = $1
AND deleted = $2;
2022-04-06 12:42:40 -05:00
-- name: InsertTemplate :one
INSERT INTO
2022-04-06 12:42:40 -05:00
templates (
id,
created_at,
updated_at,
organization_id,
"name",
provisioner,
2022-05-16 15:56:11 -05:00
active_version_id,
description
)
VALUES
2022-05-16 15:56:11 -05:00
($1, $2, $3, $4, $5, $6, $7, $8) RETURNING *;
2022-04-06 12:42:40 -05:00
-- name: UpdateTemplateActiveVersionByID :exec
UPDATE
2022-04-06 12:42:40 -05:00
templates
SET
active_version_id = $2
WHERE
id = $1;
2022-04-06 12:42:40 -05:00
-- name: UpdateTemplateDeletedByID :exec
UPDATE
2022-04-06 12:42:40 -05:00
templates
SET
deleted = $2
WHERE
id = $1;