feat: add project workspaces (DB, API, service, and UI)

New project_workspaces table with primary workspace designation.
Full CRUD routes, service with auto-primary promotion on delete,
workspace management UI in project properties panel, and workspace
data included in project/issue ancestor responses.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Forgotten
2026-02-25 08:38:46 -06:00
parent 6f7172c028
commit 29af525167
10 changed files with 6273 additions and 15 deletions

View File

@@ -0,0 +1,18 @@
CREATE TABLE "project_workspaces" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"company_id" uuid NOT NULL,
"project_id" uuid NOT NULL,
"name" text NOT NULL,
"cwd" text NOT NULL,
"repo_url" text,
"repo_ref" text,
"metadata" jsonb,
"is_primary" boolean DEFAULT false NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "project_workspaces" ADD CONSTRAINT "project_workspaces_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "project_workspaces" ADD CONSTRAINT "project_workspaces_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "project_workspaces_company_project_idx" ON "project_workspaces" USING btree ("company_id","project_id");--> statement-breakpoint
CREATE INDEX "project_workspaces_project_primary_idx" ON "project_workspaces" USING btree ("project_id","is_primary");

File diff suppressed because it is too large Load Diff

View File

@@ -127,6 +127,20 @@
"when": 1771883888199,
"tag": "0017_tiresome_gabe_jones",
"breakpoints": true
},
{
"idx": 18,
"version": "7",
"when": 1771897769629,
"tag": "0018_flat_sleepwalker",
"breakpoints": true
},
{
"idx": 19,
"version": "7",
"when": 1772029333401,
"tag": "0019_public_victor_mancha",
"breakpoints": true
}
]
}

View File

@@ -0,0 +1,32 @@
import {
boolean,
index,
jsonb,
pgTable,
text,
timestamp,
uuid,
} from "drizzle-orm/pg-core";
import { companies } from "./companies.js";
import { projects } from "./projects.js";
export const projectWorkspaces = pgTable(
"project_workspaces",
{
id: uuid("id").primaryKey().defaultRandom(),
companyId: uuid("company_id").notNull().references(() => companies.id),
projectId: uuid("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
name: text("name").notNull(),
cwd: text("cwd").notNull(),
repoUrl: text("repo_url"),
repoRef: text("repo_ref"),
metadata: jsonb("metadata").$type<Record<string, unknown>>(),
isPrimary: boolean("is_primary").notNull().default(false),
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
},
(table) => ({
companyProjectIdx: index("project_workspaces_company_project_idx").on(table.companyId, table.projectId),
projectPrimaryIdx: index("project_workspaces_project_primary_idx").on(table.projectId, table.isPrimary),
}),
);

View File

@@ -5,6 +5,20 @@ export interface ProjectGoalRef {
title: string;
}
export interface ProjectWorkspace {
id: string;
companyId: string;
projectId: string;
name: string;
cwd: string;
repoUrl: string | null;
repoRef: string | null;
metadata: Record<string, unknown> | null;
isPrimary: boolean;
createdAt: Date;
updatedAt: Date;
}
export interface Project {
id: string;
companyId: string;
@@ -18,6 +32,8 @@ export interface Project {
leadAgentId: string | null;
targetDate: string | null;
color: string | null;
workspaces: ProjectWorkspace[];
primaryWorkspace: ProjectWorkspace | null;
archivedAt: Date | null;
createdAt: Date;
updatedAt: Date;

View File

@@ -19,3 +19,18 @@ export type CreateProject = z.infer<typeof createProjectSchema>;
export const updateProjectSchema = createProjectSchema.partial();
export type UpdateProject = z.infer<typeof updateProjectSchema>;
export const createProjectWorkspaceSchema = z.object({
name: z.string().min(1),
cwd: z.string().min(1),
repoUrl: z.string().url().optional().nullable(),
repoRef: z.string().optional().nullable(),
metadata: z.record(z.unknown()).optional().nullable(),
isPrimary: z.boolean().optional().default(false),
});
export type CreateProjectWorkspace = z.infer<typeof createProjectWorkspaceSchema>;
export const updateProjectWorkspaceSchema = createProjectWorkspaceSchema.partial();
export type UpdateProjectWorkspace = z.infer<typeof updateProjectWorkspaceSchema>;