Skip to content
File

Blob: src/worker/db/durable/schema/run-do.ts

typescript52 lines
1import { index, integer, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
2 
3export const runMeta = sqliteTable(
4 "run_meta",
5 {
6 id: text("id").primaryKey(),
7 projectId: text("project_id").notNull(),
8 status: text("status").notNull(),
9 triggerType: text("trigger_type").notNull(),
10 branch: text("branch").notNull(),
11 commitSha: text("commit_sha"),
12 currentStep: integer("current_step"),
13 startedAt: integer("started_at"),
14 finishedAt: integer("finished_at"),
15 exitCode: integer("exit_code"),
16 errorMessage: text("error_message"),
17 },
18 (table) => [index("idx_run_meta_project_started_at").on(table.projectId, table.startedAt)],
19);
20 
21export const runSteps = sqliteTable(
22 "run_steps",
23 {
24 id: text("id").primaryKey(),
25 runId: text("run_id").notNull(),
26 position: integer("position").notNull(),
27 name: text("name").notNull(),
28 command: text("command").notNull(),
29 status: text("status").notNull(),
30 startedAt: integer("started_at"),
31 finishedAt: integer("finished_at"),
32 exitCode: integer("exit_code"),
33 },
34 (table) => [uniqueIndex("idx_run_steps_run_position").on(table.runId, table.position)],
35);
36 
37export const runLogs = sqliteTable(
38 "run_logs",
39 {
40 id: text("id").primaryKey(),
41 runId: text("run_id").notNull(),
42 seq: integer("seq").notNull(),
43 stream: text("stream").notNull(),
44 chunk: text("chunk").notNull(),
45 createdAt: integer("created_at").notNull(),
46 },
47 (table) => [
48 uniqueIndex("idx_run_logs_run_seq").on(table.runId, table.seq),
49 index("idx_run_logs_run_created_at").on(table.runId, table.createdAt),
50 ],
51);