Skip to content

Commit 893c54c

Browse files
committed
add metadata logic to db
1 parent d2b42b7 commit 893c54c

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DROP TABLE IF EXISTS agent_resources_monitoring;
2+
3+
DROP TYPE IF EXISTS resource_monitoring_type;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CREATE TYPE workspace_agent_monitored_resource_type AS ENUM ('memory', 'volume');
2+
3+
4+
CREATE TABLE workspace_agent_resource_monitors (
5+
agent_id uuid NOT NULL,
6+
rtype workspace_agent_monitored_resource_type NOT NULL,
7+
enabled boolean NOT NULL,
8+
threshold integer NOT NULL,
9+
metadata jsonb DEFAULT'{}'::jsonb NOT NULL,
10+
created_at timestamp with time zone NOT NULL
11+
);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- name: FetchAgentResourceMonitorsByAgentID :one
2+
SELECT
3+
*
4+
FROM
5+
workspace_agent_resource_monitors
6+
WHERE
7+
agent_id = $1;
8+
9+
-- name: InsertWorkspaceAgentResourceMonitor :one
10+
INSERT INTO
11+
workspace_agent_resource_monitors (
12+
agent_id,
13+
rtype,
14+
enabled,
15+
threshold,
16+
metadata,
17+
created_at
18+
)
19+
VALUES
20+
($1, $2, $3, $4, $5, $6) RETURNING *;

0 commit comments

Comments
 (0)