forked from farhoodlabs/paperclip
8c830eae70
Add new DB schemas: companies, agent_api_keys, approvals, cost_events, heartbeat_runs, issue_comments. Add corresponding shared types and validators. Update existing schemas (agents, goals, issues, projects) with new fields for company association, budgets, and richer metadata. Generate initial Drizzle migration. Update seed data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
22 lines
909 B
TypeScript
22 lines
909 B
TypeScript
import { pgTable, uuid, text, timestamp, index } from "drizzle-orm/pg-core";
|
|
import { agents } from "./agents.js";
|
|
import { companies } from "./companies.js";
|
|
|
|
export const agentApiKeys = pgTable(
|
|
"agent_api_keys",
|
|
{
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
agentId: uuid("agent_id").notNull().references(() => agents.id),
|
|
companyId: uuid("company_id").notNull().references(() => companies.id),
|
|
name: text("name").notNull(),
|
|
keyHash: text("key_hash").notNull(),
|
|
lastUsedAt: timestamp("last_used_at", { withTimezone: true }),
|
|
revokedAt: timestamp("revoked_at", { withTimezone: true }),
|
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
},
|
|
(table) => ({
|
|
keyHashIdx: index("agent_api_keys_key_hash_idx").on(table.keyHash),
|
|
companyAgentIdx: index("agent_api_keys_company_agent_idx").on(table.companyId, table.agentId),
|
|
}),
|
|
);
|