Skip to content

Commit 14f03d4

Browse files
chore(coderd/database): add tasks data model
1 parent f3b152b commit 14f03d4

File tree

7 files changed

+110
-0
lines changed

7 files changed

+110
-0
lines changed

coderd/database/dump.sql

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/foreign_key_constraint.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DROP TABLE task_workspace_apps;
2+
DROP TABLE tasks;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CREATE TABLE tasks (
2+
id UUID NOT NULL PRIMARY KEY,
3+
organization_id UUID NOT NULL REFERENCES organizations (id) ON DELETE CASCADE,
4+
owner_id UUID NOT NULL REFERENCES users (id) ON DELETE CASCADE,
5+
name TEXT NOT NULL,
6+
workspace_id UUID REFERENCES workspaces (id) ON DELETE CASCADE,
7+
template_version_id UUID NOT NULL REFERENCES template_versions (id) ON DELETE CASCADE,
8+
template_parameters JSONB NOT NULL DEFAULT '{}'::JSONB,
9+
prompt TEXT NOT NULL,
10+
created_at TIMESTAMPTZ NOT NULL,
11+
deleted_at TIMESTAMPTZ
12+
);
13+
14+
CREATE TABLE task_workspace_apps (
15+
task_id UUID NOT NULL REFERENCES tasks (id) ON DELETE CASCADE,
16+
workspace_build_id UUID NOT NULL REFERENCES workspace_builds (id) ON DELETE CASCADE,
17+
workspace_agent_id UUID NOT NULL REFERENCES workspace_agents (id) ON DELETE CASCADE,
18+
workspace_app_id UUID NOT NULL REFERENCES workspace_apps (id) ON DELETE CASCADE
19+
);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
INSERT INTO public.tasks VALUES (
2+
'f5a1c3e4-8b2d-4f6a-9d7e-2a8b5c9e1f3d', -- id
3+
'bb640d07-ca8a-4869-b6bc-ae61ebb2fda1', -- organization_id
4+
'30095c71-380b-457a-8995-97b8ee6e5307', -- owner_id
5+
'Test Task 1', -- name
6+
'3a9a1feb-e89d-457c-9d53-ac751b198ebe', -- workspace_id
7+
'920baba5-4c64-4686-8b7d-d1bef5683eae', -- template_version_id
8+
'{}'::JSONB, -- template_parameters
9+
'Create a React component for tasks', -- prompt
10+
'2024-11-02 13:10:00.000000+02', -- created_at
11+
NULL -- deleted_at
12+
) ON CONFLICT DO NOTHING;
13+
14+
INSERT INTO public.task_workspace_apps VALUES (
15+
'f5a1c3e4-8b2d-4f6a-9d7e-2a8b5c9e1f3d', -- task_id
16+
'a8c0b8c5-c9a8-4f33-93a4-8142e6858244', -- workspace_build_id
17+
'8fa17bbd-c48c-44c7-91ae-d4acbc755fad', -- workspace_agent_id
18+
'a47965a2-0a25-4810-8cc9-d283c86ab34c' -- workspace_app_id
19+
) ON CONFLICT DO NOTHING;

coderd/database/models.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/unique_constraint.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)