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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
CREATE TABLE IF NOT EXISTS "workflow_secrets" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"repository_id" uuid NOT NULL REFERENCES "repositories"("id") ON DELETE CASCADE,
"name" text NOT NULL,
"encrypted_value" text NOT NULL,
"created_by" uuid REFERENCES "users"("id") ON DELETE SET NULL,
"created_at" timestamptz NOT NULL DEFAULT now(),
"updated_at" timestamptz NOT NULL DEFAULT now()
);
CREATE UNIQUE INDEX IF NOT EXISTS "workflow_secrets_repo_name_uq"
ON "workflow_secrets" ("repository_id", "name");
CREATE INDEX IF NOT EXISTS "workflow_secrets_repo_idx"
ON "workflow_secrets" ("repository_id");
CREATE TABLE IF NOT EXISTS "workflow_dispatch_inputs" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"workflow_id" uuid NOT NULL REFERENCES "workflows"("id") ON DELETE CASCADE,
"name" text NOT NULL,
"type" text NOT NULL CHECK (type IN ('string', 'boolean', 'choice', 'number')),
"required" boolean NOT NULL DEFAULT false,
"default_value" text,
"options" jsonb,
"description" text
);
CREATE UNIQUE INDEX IF NOT EXISTS "workflow_dispatch_inputs_wf_name_uq"
ON "workflow_dispatch_inputs" ("workflow_id", "name");
CREATE TABLE IF NOT EXISTS "workflow_run_cache" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"repository_id" uuid NOT NULL REFERENCES "repositories"("id") ON DELETE CASCADE,
"cache_key" text NOT NULL,
"scope" text NOT NULL DEFAULT 'repo',
"scope_ref" text,
"content_hash" text NOT NULL,
"content" bytea NOT NULL,
"size_bytes" bigint NOT NULL,
"created_at" timestamptz NOT NULL DEFAULT now(),
"last_accessed_at" timestamptz NOT NULL DEFAULT now()
);
CREATE UNIQUE INDEX IF NOT EXISTS "workflow_run_cache_repo_key_scope_uq"
ON "workflow_run_cache" ("repository_id", "cache_key", "scope", "scope_ref");
CREATE INDEX IF NOT EXISTS "workflow_run_cache_repo_lru_idx"
ON "workflow_run_cache" ("repository_id", "last_accessed_at");
CREATE TABLE IF NOT EXISTS "workflow_runner_pool" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"worker_id" text NOT NULL UNIQUE,
"status" text NOT NULL CHECK (status IN ('idle', 'busy', 'draining', 'dead')),
"current_run_id" uuid REFERENCES "workflow_runs"("id") ON DELETE SET NULL,
"warmed_at" timestamptz NOT NULL DEFAULT now(),
"last_heartbeat_at" timestamptz NOT NULL DEFAULT now(),
"capacity" integer NOT NULL DEFAULT 1
);
CREATE INDEX IF NOT EXISTS "workflow_runner_pool_status_idx"
ON "workflow_runner_pool" ("status");
|