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>
30 lines
955 B
TypeScript
30 lines
955 B
TypeScript
import {
|
|
type AnyPgColumn,
|
|
pgTable,
|
|
uuid,
|
|
text,
|
|
timestamp,
|
|
index,
|
|
} from "drizzle-orm/pg-core";
|
|
import { agents } from "./agents.js";
|
|
import { companies } from "./companies.js";
|
|
|
|
export const goals = pgTable(
|
|
"goals",
|
|
{
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
companyId: uuid("company_id").notNull().references(() => companies.id),
|
|
title: text("title").notNull(),
|
|
description: text("description"),
|
|
level: text("level").notNull().default("task"),
|
|
status: text("status").notNull().default("planned"),
|
|
parentId: uuid("parent_id").references((): AnyPgColumn => goals.id),
|
|
ownerAgentId: uuid("owner_agent_id").references(() => agents.id),
|
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
},
|
|
(table) => ({
|
|
companyIdx: index("goals_company_idx").on(table.companyId),
|
|
}),
|
|
);
|