-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathjobs.ts
More file actions
58 lines (57 loc) · 2.15 KB
/
Copy pathjobs.ts
File metadata and controls
58 lines (57 loc) · 2.15 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
55
56
57
58
import {
sqliteTable,
text,
integer,
real,
index
} from "drizzle-orm/sqlite-core";
import { jsonText } from "./helpers.js";
export const jobs = sqliteTable(
"nodetool_jobs",
{
id: text("id").primaryKey(),
user_id: text("user_id").notNull(),
job_type: text("job_type").notNull().default(""),
workflow_id: text("workflow_id").notNull(),
status: text("status").notNull().default("scheduled"),
name: text("name").default(""),
graph: jsonText<Record<string, unknown>>()("graph"),
params: jsonText<Record<string, unknown>>()("params"),
worker_id: text("worker_id"),
heartbeat_at: text("heartbeat_at"),
started_at: text("started_at"),
finished_at: text("finished_at"),
completed_at: text("completed_at"),
failed_at: text("failed_at"),
error: text("error"),
error_message: text("error_message"),
cost: real("cost"),
logs: jsonText<Record<string, unknown>[]>()("logs"),
retry_count: integer("retry_count").notNull().default(0),
max_retries: integer("max_retries").notNull().default(3),
version: integer("version").notNull().default(0),
suspended_node_id: text("suspended_node_id"),
suspension_reason: text("suspension_reason"),
suspension_state_json: jsonText<Record<string, unknown>>()(
"suspension_state_json"
),
suspension_metadata_json: jsonText<Record<string, unknown>>()(
"suspension_metadata_json"
),
execution_strategy: text("execution_strategy"),
execution_id: text("execution_id"),
// The server instance executing this run (Fly machine id). Null on a
// single-machine deployment; see packages/websocket/src/lib/instance-id.ts.
runner_instance: text("runner_instance"),
metadata_json: jsonText<Record<string, unknown>>()("metadata_json"),
created_at: text("created_at").notNull(),
updated_at: text("updated_at").notNull()
},
(table) => [
index("idx_jobs_status").on(table.status),
index("idx_jobs_updated_at").on(table.updated_at),
index("idx_jobs_worker_id").on(table.worker_id),
index("idx_jobs_heartbeat_at").on(table.heartbeat_at),
index("idx_jobs_recovery").on(table.status, table.heartbeat_at)
]
);