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) <noreply@anthropic.com>
This commit is contained in:
2026-03-15 16:30:46 +01:00
parent 92afac3eb7
commit 629e14f60c
3 changed files with 6 additions and 0 deletions

View File

@@ -33,6 +33,9 @@ export const threads = sqliteTable("threads", {
name: text("name").notNull(), name: text("name").notNull(),
status: text("status").notNull().default("active"), status: text("status").notNull().default("active"),
resolvedCandidateId: integer("resolved_candidate_id"), resolvedCandidateId: integer("resolved_candidate_id"),
categoryId: integer("category_id")
.notNull()
.references(() => categories.id),
createdAt: integer("created_at", { mode: "timestamp" }) createdAt: integer("created_at", { mode: "timestamp" })
.notNull() .notNull()
.$defaultFn(() => new Date()), .$defaultFn(() => new Date()),

View File

@@ -27,10 +27,12 @@ export const updateCategorySchema = z.object({
// Thread schemas // Thread schemas
export const createThreadSchema = z.object({ export const createThreadSchema = z.object({
name: z.string().min(1, "Thread name is required"), name: z.string().min(1, "Thread name is required"),
categoryId: z.number().int().positive(),
}); });
export const updateThreadSchema = z.object({ export const updateThreadSchema = z.object({
name: z.string().min(1).optional(), name: z.string().min(1).optional(),
categoryId: z.number().int().positive().optional(),
}); });
// Candidate schemas (same fields as items) // Candidate schemas (same fields as items)

View File

@@ -37,6 +37,7 @@ export function createTestDb() {
name TEXT NOT NULL, name TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'active', status TEXT NOT NULL DEFAULT 'active',
resolved_candidate_id INTEGER, resolved_candidate_id INTEGER,
category_id INTEGER NOT NULL REFERENCES categories(id),
created_at INTEGER NOT NULL DEFAULT (unixepoch()), created_at INTEGER NOT NULL DEFAULT (unixepoch()),
updated_at INTEGER NOT NULL DEFAULT (unixepoch()) updated_at INTEGER NOT NULL DEFAULT (unixepoch())
) )