Files
PaperClipAI/packages/db/src/schema/projects.ts
T
scotttongandClaude Opus 4.8 744f9f7428 PAP-69: project icon data layer (schema + migration + type + validator + portability)
Part 1 of PAP-68. Adds the `icon` column to projects, mirroring agents.icon:
- DB: `icon text` on projects schema + 0094 migration (ADD COLUMN + one-time
  bulk reset of all project colors to NULL per board decision #1) with matching
  Drizzle snapshot/journal.
- Type: `Project.icon` and the portability project manifest entry.
- Validator: `icon` on projectFields (create + update); loosely typed as string
  until PROJECT_ICON_NAMES lands in part 3.
- Portability: export + import round-trip `icon` alongside `color`.
- Tests: DB-backed create/round-trip + null default; portability export/import
  round-trip assertion.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-05 15:18:53 -07:00

32 lines
1.3 KiB
TypeScript

import { pgTable, uuid, text, timestamp, date, index, jsonb } from "drizzle-orm/pg-core";
import type { AgentEnvConfig } from "@paperclipai/shared";
import { companies } from "./companies.js";
import { goals } from "./goals.js";
import { agents } from "./agents.js";
export const projects = pgTable(
"projects",
{
id: uuid("id").primaryKey().defaultRandom(),
companyId: uuid("company_id").notNull().references(() => companies.id),
goalId: uuid("goal_id").references(() => goals.id),
name: text("name").notNull(),
description: text("description"),
status: text("status").notNull().default("backlog"),
leadAgentId: uuid("lead_agent_id").references(() => agents.id),
targetDate: date("target_date"),
color: text("color"),
icon: text("icon"),
env: jsonb("env").$type<AgentEnvConfig>(),
pauseReason: text("pause_reason"),
pausedAt: timestamp("paused_at", { withTimezone: true }),
executionWorkspacePolicy: jsonb("execution_workspace_policy").$type<Record<string, unknown>>(),
archivedAt: timestamp("archived_at", { withTimezone: true }),
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
},
(table) => ({
companyIdx: index("projects_company_idx").on(table.companyId),
}),
);