-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathworkspaceresources.sql
More file actions
54 lines (47 loc) · 1.29 KB
/
workspaceresources.sql
File metadata and controls
54 lines (47 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-- name: GetWorkspaceResourceByID :one
SELECT
*
FROM
workspace_resources
WHERE
id = $1;
-- name: GetWorkspaceResourcesByJobID :many
SELECT
*
FROM
workspace_resources
WHERE
job_id = $1;
-- name: GetWorkspaceResourcesByJobIDs :many
SELECT
*
FROM
workspace_resources
WHERE
job_id = ANY(@ids :: uuid [ ]);
-- name: GetWorkspaceResourcesCreatedAfter :many
SELECT * FROM workspace_resources WHERE created_at > $1;
-- name: InsertWorkspaceResource :one
INSERT INTO
workspace_resources (id, created_at, job_id, transition, type, name, hide, icon, instance_type, daily_cost, module_path)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING *;
-- name: GetWorkspaceResourceMetadataByResourceIDs :many
SELECT
*
FROM
workspace_resource_metadata
WHERE
workspace_resource_id = ANY(@ids :: uuid [ ]) ORDER BY id ASC;
-- name: InsertWorkspaceResourceMetadata :many
INSERT INTO
workspace_resource_metadata
SELECT
@workspace_resource_id :: uuid AS workspace_resource_id,
unnest(@key :: text [ ]) AS key,
unnest(@value :: text [ ]) AS value,
unnest(@sensitive :: boolean [ ]) AS sensitive RETURNING *;
-- name: GetWorkspaceResourceMetadataCreatedAfter :many
SELECT * FROM workspace_resource_metadata WHERE workspace_resource_id = ANY(
SELECT id FROM workspace_resources WHERE created_at > $1
);