feat(11-01): schema, service, and tests for sort_order + reorderCandidates

- Add sortOrder REAL column to threadCandidates schema (default 0)
- Add sort_order column to test helper CREATE TABLE
- Add reorderCandidatesSchema to shared/schemas.ts
- Add ReorderCandidates type to shared/types.ts
- getThreadWithCandidates now orders candidates by sort_order ASC
- createCandidate appends at max sort_order + 1000 (first = 1000)
- Add reorderCandidates service function (transaction, active-only guard)
- Add 5 new tests: ordering, appending, reorder success, resolved guard, missing thread
This commit is contained in:
2026-03-16 22:21:42 +01:00
parent 2986bdd2e5
commit f01d71d6b4
9 changed files with 656 additions and 2 deletions

View File

@@ -57,6 +57,7 @@ export function createTestDb() {
status TEXT NOT NULL DEFAULT 'researching',
pros TEXT,
cons TEXT,
sort_order REAL NOT NULL DEFAULT 0,
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
updated_at INTEGER NOT NULL DEFAULT (unixepoch())
)