File
Blob: src/worker/db/d1/schema/run-index.ts
| 1 | import { desc } from "drizzle-orm"; |
| 2 | import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core"; |
| 3 | |
| 4 | export const runIndex = sqliteTable( |
| 5 | "run_index", |
| 6 | { |
| 7 | id: text("id").primaryKey(), |
| 8 | projectId: text("project_id").notNull(), |
| 9 | triggeredByUserId: text("triggered_by_user_id"), |
| 10 | triggerType: text("trigger_type").notNull(), |
| 11 | branch: text("branch").notNull(), |
| 12 | commitSha: text("commit_sha"), |
| 13 | status: text("status").notNull(), |
| 14 | dispatchMode: text("dispatch_mode").notNull(), |
| 15 | executionRuntime: text("execution_runtime").notNull(), |
| 16 | queuedAt: integer("queued_at").notNull(), |
| 17 | startedAt: integer("started_at"), |
| 18 | finishedAt: integer("finished_at"), |
| 19 | exitCode: integer("exit_code"), |
| 20 | }, |
| 21 | (table) => [ |
| 22 | index("idx_run_index_project_queued_at").on(table.projectId, desc(table.queuedAt)), |
| 23 | index("idx_run_index_project_started_at").on(table.projectId, desc(table.startedAt)), |
| 24 | index("idx_run_index_user_queued_at").on(table.triggeredByUserId, desc(table.queuedAt)), |
| 25 | index("idx_run_index_status_queued_at").on(table.status, desc(table.queuedAt)), |
| 26 | ], |
| 27 | ); |