3.7.3 Board CRUD service + API — create (seed columns) / rename / set-default / delete (guards)
Estimate: 28m · Depends on: 3.7.2, 3.1.3
The board lifecycle, 4-layer (Route → Service → Repository → Prisma) with the explicit workspaceId gate (finding #26). boardsService: createBoard(projectId, { name, type }) — creates the board AND seeds its default columns off the project workflow (REUSE the 3.1 board-bootstrap helper so a new board is immediately usable), non-default; renameBoard; setDefaultBoard — flips the project’s default in one tx (clears the prior default, sets the new — preserving the one-default invariant); deleteBoard — removes the board + its column/config rows (issues are untouched — they belong to the project), with two guards: the last board cannot be deleted (typed error), and deleting the default promotes the next board (by position) to default. Membership-gated with a // TODO(6.4): project-admin note (mirror 2.2.5 / 3.3.3). Routes (board-scoped, not project-key — consistent with the 3.1.6 active-project routing): GET /api/boards (list for the active project), POST /api/boards (create), PATCH /api/boards/[id] (rename / setDefault), DELETE /api/boards/[id]; HTTP-only, typed-error→status (400 invalid, 403 wrong workspace / not admited later, 404 missing, 409 last-board).
Acceptance criteria
createBoard(+ seeds default columns via the 3.1 bootstrap),renameBoard,setDefaultBoard(one-default invariant in one tx),deleteBoard(removes board + config, NOT issues) exist, own their transaction, return DTOs, enforce theworkspaceIdgate.- Guards: last-board delete → typed 409; deleting the default promotes the next board by position; a
// TODO(6.4)project-admin note is present (no early RBAC). GET/POST /api/boards+PATCH/DELETE /api/boards/[id]are HTTP-only (one service call, typed-error→status); a cross-workspace board is 404.- Vitest (real Postgres): create-with-columns, rename, set-default (invariant holds), delete (issues survive), the last-board + promote-default guards, cross-workspace denial.
Context refs
lib/services/boardsService.ts+lib/repositories/boardRepository.ts(3.1.3) — the service/repo to extend; the 3.1 board-bootstrap (auto-seed columns) helper to reuse forcreateBoardlib/services/workflowsService.ts(2.2.5) — the membership-gate + "RBAC later" precedent;lib/dto/boards.ts/boardMappers.ts;motir-core/CLAUDE.md(4-layer)