feat: add project_goals many-to-many join table
Create project_goals join table with composite PK (project_id, goal_id), backfill from existing projects.goal_id, and update the project service to read/write through the join table. Shared types now include goalIds and goals arrays on Project. Legacy goalId column is kept in sync. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ export { agentRuntimeState } from "./agent_runtime_state.js";
|
||||
export { agentTaskSessions } from "./agent_task_sessions.js";
|
||||
export { agentWakeupRequests } from "./agent_wakeup_requests.js";
|
||||
export { projects } from "./projects.js";
|
||||
export { projectGoals } from "./project_goals.js";
|
||||
export { goals } from "./goals.js";
|
||||
export { issues } from "./issues.js";
|
||||
export { issueApprovals } from "./issue_approvals.js";
|
||||
|
||||
21
packages/db/src/schema/project_goals.ts
Normal file
21
packages/db/src/schema/project_goals.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { pgTable, uuid, timestamp, index, primaryKey } from "drizzle-orm/pg-core";
|
||||
import { companies } from "./companies.js";
|
||||
import { projects } from "./projects.js";
|
||||
import { goals } from "./goals.js";
|
||||
|
||||
export const projectGoals = pgTable(
|
||||
"project_goals",
|
||||
{
|
||||
projectId: uuid("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
||||
goalId: uuid("goal_id").notNull().references(() => goals.id, { onDelete: "cascade" }),
|
||||
companyId: uuid("company_id").notNull().references(() => companies.id),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => ({
|
||||
pk: primaryKey({ columns: [table.projectId, table.goalId] }),
|
||||
projectIdx: index("project_goals_project_idx").on(table.projectId),
|
||||
goalIdx: index("project_goals_goal_idx").on(table.goalId),
|
||||
companyIdx: index("project_goals_company_idx").on(table.companyId),
|
||||
}),
|
||||
);
|
||||
Reference in New Issue
Block a user