feat(categories): data model + CRUD API (#6, slice 1) #50
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/v6.2-categories-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
First of three slices for #6 — Categories for motifs & entries (v6.2). Backend foundation only; UI follows in slices 2–3.
Per the design sign-off: many categories per item (junction tables) and one shared set for both entries and motifs, project-scoped (distinct from user-scoped freeform tags).
Changes
categories(project_id NOT NULL→projectsON DELETE CASCADE,UNIQUE(project_id, name), optionalcolor), plusentry_categoriesandmotif_categoriesjunction tables (PK on the pair, cascade on both sides). Indexed for lookup by project and by category.routes/categories.ts—GET(active-project-scoped, withentry_count/motif_count),POST,PATCH(rename/recolor),DELETE. Hex color normalized to#rrggbb(invalid → null);409on duplicate name; mutate paths verify project access viacanAccessProject. Mounted at/api/categoriesafterrequireAuth.categoriesto the integration-test cleanup (helpers.ts).Drive-by fix
admin.test.tshard-coded the installed version as'6.0.0'; the v6.1.0 release bump broke it (it's currently red onmain, since the release commit was pushed directly, bypassing PR CI). It now asserts againstgetInstalledVersion()— the same source the endpoint reads — so future version bumps won't break it.Verification (dev server)
[test] migration applied: 040_categories.sql)tscbuild clean ✅No CHANGELOG entry yet — categories aren't user-visible until the UI slices land; I'll add it when the feature is usable (and it'll roll into the v6.2.0 release notes).
🤖 Generated with Claude Code
First slice of categories — a curated, per-project taxonomy for entries and motifs (distinct from user-scoped freeform tags). - Migration 040: `categories` (project-scoped, UNIQUE(project_id, name), optional hex color) + `entry_categories` / `motif_categories` junction tables (many-to-many, shared set across both entry and motif types). - `routes/categories.ts`: list (active-project-scoped, with usage counts), create, PATCH (rename/recolor), delete. Hex color normalized/validated; 409 on duplicate name; project-access checks on mutate. - Mounted at /api/categories; categories added to test cleanup. Also fixes admin.test.ts pinning the installed version to a literal ('6.0.0') — it now asserts against getInstalledVersion() so release bumps don't break it (the v6.1.0 bump had). 8 new tests; full API suite green (158). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>