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,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),
}),
);