Pilot: extract holds aggregate to Drizzle #840

Closed
opened 2026-05-04 20:28:10 +00:00 by claude-desktop · 0 comments
Collaborator

As a maintainer, I want the smallest aggregate (holds, 4 fns ~30 LOC) split out of db.ts and rewritten on Drizzle, so that the migration pattern is proven on minimal surface before tackling load-bearing aggregates.

Acceptance criteria

Extraction

  • New file apps/server/src/infrastructure/database/holds.ts.
  • Functions moved: addHold, removeHold, hasHold, listHolds.
  • Type HoldRow moved + re-exported under same name.
  • All callers (domain/workflow/deps.ts, others — grep from.*database/db for these symbols) updated to import from new path.

Drizzle

  • schema/holds.ts defines holds table mirroring current SQL shape.
  • Functions rewritten using Drizzle query builder.
  • getDb() shared — no second connection. Wrapper helper orm() (recompute per call, no memo) in db/client.ts.

Tests

  • Existing hold tests in db.test.ts extracted to holds.test.ts, all pass.
  • Round-trip test: insert via Drizzle, read via raw getDb().query(...) — same row.

Out of scope

  • Migrating other aggregates.
  • Naming convention changes beyond bridge style locked in foundation story.

References

  • apps/server/src/infrastructure/database/db.ts:1324-1383 (current hold fns).
  • Foundation story (#839) must merge first.
**As a** maintainer, **I want** the smallest aggregate (`holds`, 4 fns ~30 LOC) split out of `db.ts` and rewritten on Drizzle, **so that** the migration pattern is proven on minimal surface before tackling load-bearing aggregates. ## Acceptance criteria ### Extraction - [ ] New file `apps/server/src/infrastructure/database/holds.ts`. - [ ] Functions moved: `addHold`, `removeHold`, `hasHold`, `listHolds`. - [ ] Type `HoldRow` moved + re-exported under same name. - [ ] All callers (`domain/workflow/deps.ts`, others — grep `from.*database/db` for these symbols) updated to import from new path. ### Drizzle - [ ] `schema/holds.ts` defines `holds` table mirroring current SQL shape. - [ ] Functions rewritten using Drizzle query builder. - [ ] `getDb()` shared — no second connection. Wrapper helper `orm()` (recompute per call, no memo) in `db/client.ts`. ### Tests - [ ] Existing hold tests in `db.test.ts` extracted to `holds.test.ts`, all pass. - [ ] Round-trip test: insert via Drizzle, read via raw `getDb().query(...)` — same row. ## Out of scope - Migrating other aggregates. - Naming convention changes beyond bridge style locked in foundation story. ## References - `apps/server/src/infrastructure/database/db.ts:1324-1383` (current hold fns). - Foundation story (#839) must merge first.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks#840
No description provided.