From 629e14f60c10a51fc1cf779295d3dce38f2cedd3 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Sun, 15 Mar 2026 16:30:46 +0100 Subject: [PATCH] feat(04-01): add categoryId to threads schema, Zod schemas, and test helper - Add categoryId column with FK to categories on threads table - Update createThreadSchema to require categoryId - Update updateThreadSchema to allow optional categoryId - Update test helper CREATE TABLE to include category_id Co-Authored-By: Claude Opus 4.6 (1M context) --- src/db/schema.ts | 3 +++ src/shared/schemas.ts | 2 ++ tests/helpers/db.ts | 1 + 3 files changed, 6 insertions(+) diff --git a/src/db/schema.ts b/src/db/schema.ts index 67b6b8a..d182609 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -33,6 +33,9 @@ export const threads = sqliteTable("threads", { name: text("name").notNull(), status: text("status").notNull().default("active"), resolvedCandidateId: integer("resolved_candidate_id"), + categoryId: integer("category_id") + .notNull() + .references(() => categories.id), createdAt: integer("created_at", { mode: "timestamp" }) .notNull() .$defaultFn(() => new Date()), diff --git a/src/shared/schemas.ts b/src/shared/schemas.ts index d73a1c9..724a48b 100644 --- a/src/shared/schemas.ts +++ b/src/shared/schemas.ts @@ -27,10 +27,12 @@ export const updateCategorySchema = z.object({ // Thread schemas export const createThreadSchema = z.object({ name: z.string().min(1, "Thread name is required"), + categoryId: z.number().int().positive(), }); export const updateThreadSchema = z.object({ name: z.string().min(1).optional(), + categoryId: z.number().int().positive().optional(), }); // Candidate schemas (same fields as items) diff --git a/tests/helpers/db.ts b/tests/helpers/db.ts index a500b35..1de3956 100644 --- a/tests/helpers/db.ts +++ b/tests/helpers/db.ts @@ -37,6 +37,7 @@ export function createTestDb() { name TEXT NOT NULL, status TEXT NOT NULL DEFAULT 'active', resolved_candidate_id INTEGER, + category_id INTEGER NOT NULL REFERENCES categories(id), created_at INTEGER NOT NULL DEFAULT (unixepoch()), updated_at INTEGER NOT NULL DEFAULT (unixepoch()) )