/ opencodehub / src / db / schema / pipeline-runners.ts
Swadhin Biswas feat(api): add runner, analytics, packages, and security services · 3/6/2026
28f7954
28 lines · 1.1 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

import { relations } from "drizzle-orm";
import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
import { repositories } from "./repositories";

export const pipelineRunners = pgTable("pipeline_runners", {
    id: text("id").primaryKey(),
    repositoryId: text("repository_id").references(() => repositories.id, { onDelete: "cascade" }), // If null, global runner (future)
    token: text("token").notNull(), // Stored as a one-way hash
    name: text("name").notNull(),
    os: text("os"),
    arch: text("arch"),
    version: text("version"),
    status: text("status").notNull().default("offline"), // online, offline, busy
    lastSeenAt: timestamp("last_seen_at"),
    createdAt: timestamp("created_at").notNull().defaultNow(),
});

export const pipelineRunnersRelations = relations(pipelineRunners, ({ one }) => ({
    repository: one(repositories, {
        fields: [pipelineRunners.repositoryId],
        references: [repositories.id],
    }),
}));

export type PipelineRunner = typeof pipelineRunners.$inferSelect;
export type NewPipelineRunner = typeof pipelineRunners.$inferInsert;