feat: add issue labels (DB schema, API, and service)
New labels and issue_labels tables with cascade deletes, unique per-company name constraint. CRUD routes for labels, label filtering on issue list, and label sync on issue create/update. All issue responses now include labels array. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,9 +12,12 @@ 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 { projectWorkspaces } from "./project_workspaces.js";
|
||||
export { projectGoals } from "./project_goals.js";
|
||||
export { goals } from "./goals.js";
|
||||
export { issues } from "./issues.js";
|
||||
export { labels } from "./labels.js";
|
||||
export { issueLabels } from "./issue_labels.js";
|
||||
export { issueApprovals } from "./issue_approvals.js";
|
||||
export { issueComments } from "./issue_comments.js";
|
||||
export { assets } from "./assets.js";
|
||||
|
||||
20
packages/db/src/schema/issue_labels.ts
Normal file
20
packages/db/src/schema/issue_labels.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { pgTable, uuid, timestamp, index, primaryKey } from "drizzle-orm/pg-core";
|
||||
import { companies } from "./companies.js";
|
||||
import { issues } from "./issues.js";
|
||||
import { labels } from "./labels.js";
|
||||
|
||||
export const issueLabels = pgTable(
|
||||
"issue_labels",
|
||||
{
|
||||
issueId: uuid("issue_id").notNull().references(() => issues.id, { onDelete: "cascade" }),
|
||||
labelId: uuid("label_id").notNull().references(() => labels.id, { onDelete: "cascade" }),
|
||||
companyId: uuid("company_id").notNull().references(() => companies.id, { onDelete: "cascade" }),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => ({
|
||||
pk: primaryKey({ columns: [table.issueId, table.labelId], name: "issue_labels_pk" }),
|
||||
issueIdx: index("issue_labels_issue_idx").on(table.issueId),
|
||||
labelIdx: index("issue_labels_label_idx").on(table.labelId),
|
||||
companyIdx: index("issue_labels_company_idx").on(table.companyId),
|
||||
}),
|
||||
);
|
||||
18
packages/db/src/schema/labels.ts
Normal file
18
packages/db/src/schema/labels.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { pgTable, uuid, text, timestamp, index, uniqueIndex } from "drizzle-orm/pg-core";
|
||||
import { companies } from "./companies.js";
|
||||
|
||||
export const labels = pgTable(
|
||||
"labels",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
companyId: uuid("company_id").notNull().references(() => companies.id, { onDelete: "cascade" }),
|
||||
name: text("name").notNull(),
|
||||
color: text("color").notNull(),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => ({
|
||||
companyIdx: index("labels_company_idx").on(table.companyId),
|
||||
companyNameIdx: uniqueIndex("labels_company_name_idx").on(table.companyId, table.name),
|
||||
}),
|
||||
);
|
||||
Reference in New Issue
Block a user