Files
STTracker/docs/plans/001-phase1-sdd/reports/task-2-report.md
T
Lucas WintherandClaude Opus 5.5 be04fab098 docs: phase 1 handoff, execution ledger and task reports
Captures the owner's requirements and decisions from the planning
conversation, current branch/worktree state, open tasks 17-19, pending
owner decisions and the controller's rulings so a new agent can resume.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 04:53:02 +01:00

26 lines
2.6 KiB
Markdown

# Task 2 report: schema migration and Database types
Status: DONE_WITH_CONCERNS. Branch `worktree-agent-a36198c2788ae2f86`. Commits: da04adb `feat(db): initial schema`, then the fix-round commit `fix(db): ...`.
## Original work (da04adb)
- Worktree was on main; fast-forwarded to feat/phase1 (27ec24e) before starting.
- `packages/db/src/schema.ts`: 26 table interfaces and `Database`. No `Generated<>`, since all IDs and values come from app code. `favorite` is a number (0/1), JSON columns are strings.
- `packages/db/src/migrations/0001_initial.ts`: schema builder only, with text/integer/real. NOT NULL unless the brief says null. FK columns have `references` and an index. All brief unique constraints and the (user_id, listened_at) and (status, run_at) indexes are present. Extra indexes: works.media_type, works.merged_into_id, attachments.sha256, (entity, entity_id) on attachment_links and user_history, (target_entity, target_id) on source_records, (user_id, status) on change_events, jobs.lock_key.
- `migrations/index.ts` registers `0001_initial`. `AGENTS.md` now says UUIDv7 (`newId()`).
- `packages/db/test/schema.test.ts`: unique constraint test from the brief.
- TDD: RED was `SQLiteError: no such table: users`. GREEN on SQLite and Postgres.
- Decisions: `works.merged_into_id` and `cover_attachment_id` have no FK. `attachments.size` is `integer`, which is int4 on Postgres. No column defaults.
## Fix round 1
1. `down` in 0001_initial.ts drops all 26 tables in the reverse order given. New test "migrating down removes the tables" uses `Migrator.migrateDown()` and asserts `select 1 from users` rejects, on both dialects.
2. `packages/db/src/testing.ts`: for Postgres, `beforeAll` creates and migrates a template `st_tpl_<random>` and closes its connections. `beforeEach` runs `create database st_<random> template st_tpl_<random>`. `afterEach` closes the connection and drops the test DB. `afterAll` drops the template. All hooks have a 30 000 ms timeout. SQLite is unchanged (`:memory:` plus migrate).
3. `EntryStatus` union added in schema.ts and used for `entries.status`. The test uses `"planned" as const`.
## Verification
- `bun run typecheck`: clean.
- `bun test packages/db` (SQLite): 7 pass, 0 fail.
- `TEST_POSTGRES_URL=postgres://postgres:postgres@127.0.0.1:55432/postgres bun test packages/db`, run 3 times in a row: 13 pass, 0 fail each time. No hook timeouts.
## Concerns
- The shared path `/home/user/STTracker/.superpowers/...` is write-blocked for this worktree-isolated agent. This report is at `.superpowers/sdd/001-phase1-own-your-data/task-2-report.md` inside the worktree, uncommitted, and the controller needs to copy it over.