Add pending_approval agent status, permissions jsonb column, and AgentPermissions type with canCreateAgents flag. Add approval_comments table and ApprovalComment type. Extend approval statuses with revision_requested. Add validators for permission updates, approval revision requests, resubmission, and approval comments. Add requireBoardApprovalForNewAgents to company update schema. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import { pgTable, uuid, text, timestamp, index } from "drizzle-orm/pg-core";
|
|
import { companies } from "./companies.js";
|
|
import { approvals } from "./approvals.js";
|
|
import { agents } from "./agents.js";
|
|
|
|
export const approvalComments = pgTable(
|
|
"approval_comments",
|
|
{
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
companyId: uuid("company_id").notNull().references(() => companies.id),
|
|
approvalId: uuid("approval_id").notNull().references(() => approvals.id),
|
|
authorAgentId: uuid("author_agent_id").references(() => agents.id),
|
|
authorUserId: text("author_user_id"),
|
|
body: text("body").notNull(),
|
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
},
|
|
(table) => ({
|
|
companyIdx: index("approval_comments_company_idx").on(table.companyId),
|
|
approvalIdx: index("approval_comments_approval_idx").on(table.approvalId),
|
|
approvalCreatedIdx: index("approval_comments_approval_created_idx").on(
|
|
table.approvalId,
|
|
table.createdAt,
|
|
),
|
|
}),
|
|
);
|