plan(iter-3.5): add Phase 0.8 — schema bootstrap fix #20

Merged
deco merged 1 commit from plan/phase-0.8-schema-bootstrap into main 2026-05-20 22:03:51 +03:00
Owner

Summary

Adds Phase 0.8 to the iter-3.4 stream-a-thon plan, capturing a foot-gun caught during Phase 1.1 dev on 2026-05-20: a fresh sources.db is missing group_name / group_uuid on the teams table, because lib/database.ts:initializeDatabase() only creates (team_id, team_name). Those columns were added later via standalone migration scripts that aren't auto-run on cold start, so /api/streams returns SQLITE_ERROR: no such column: t.group_name on any cold checkout.

Event-day risk: if a hot-spare laptop is provisioned at the venue, this fires on first boot.

What the plan now says

New Phase 0.8 section between Phase 0.7 and Phase 1, total 0.25 d, runs alongside Phase 0.7 (no shared surface):

  • 0.8.1 Fold group_name TEXT + group_uuid TEXT into the CREATE TABLE IF NOT EXISTS for teams in lib/database.ts. Keep the migration scripts (idempotent — they check PRAGMA table_info first).
  • 0.8.2 Array.isArray(...) guard in the home page's API-response unwrap (app/page.tsx:80-81) so future schema-drift bugs degrade to "empty list" rather than crashing the React render.
  • 0.8.3 New lib/__tests__/database.test.ts that opens an in-memory SQLite, runs initializeDatabase(), and asserts every column referenced by runtime route SELECTs is present. Catches future drift in CI.

Day-math updated: +0.25 d → total nominal ~29.80 d; honest slack narrows to +0.20 to +1.20 d (still positive).

Test plan

This PR is plan-only. The implementation work happens against the plan in a subsequent code PR (won't be bundled into the in-flight Phase 1 branch / PR #19, since that's already in review).

Out of scope

  • The fix itself — code lands in a follow-up PR.
  • Backfilling group_name / group_uuid for existing populated DBs — migration scripts already do that; this is about fresh-DB bootstrap only.
## Summary Adds **Phase 0.8** to the iter-3.4 stream-a-thon plan, capturing a foot-gun caught during Phase 1.1 dev on 2026-05-20: a fresh `sources.db` is missing `group_name` / `group_uuid` on the `teams` table, because `lib/database.ts:initializeDatabase()` only creates `(team_id, team_name)`. Those columns were added later via standalone migration scripts that aren't auto-run on cold start, so `/api/streams` returns `SQLITE_ERROR: no such column: t.group_name` on any cold checkout. **Event-day risk:** if a hot-spare laptop is provisioned at the venue, this fires on first boot. ## What the plan now says New Phase 0.8 section between Phase 0.7 and Phase 1, total **0.25 d**, runs alongside Phase 0.7 (no shared surface): - **0.8.1** Fold `group_name TEXT` + `group_uuid TEXT` into the `CREATE TABLE IF NOT EXISTS` for teams in `lib/database.ts`. Keep the migration scripts (idempotent — they check `PRAGMA table_info` first). - **0.8.2** `Array.isArray(...)` guard in the home page's API-response unwrap (`app/page.tsx:80-81`) so future schema-drift bugs degrade to "empty list" rather than crashing the React render. - **0.8.3** New `lib/__tests__/database.test.ts` that opens an in-memory SQLite, runs `initializeDatabase()`, and asserts every column referenced by runtime route SELECTs is present. Catches future drift in CI. Day-math updated: **+0.25 d → total nominal ~29.80 d**; honest slack narrows to **+0.20 to +1.20 d** (still positive). ## Test plan This PR is plan-only. The implementation work happens against the plan in a subsequent code PR (won't be bundled into the in-flight Phase 1 branch / PR #19, since that's already in review). ## Out of scope - The fix itself — code lands in a follow-up PR. - Backfilling `group_name` / `group_uuid` for existing populated DBs — migration scripts already do that; this is about fresh-DB bootstrap only.
plan(iter-3.5): add Phase 0.8 — schema bootstrap fix
All checks were successful
Lint and Build / build (pull_request) Successful in 2m56s
e8ad2a60c1
Caught during Phase 1.1 dev on 2026-05-20: a fresh worktree (no
sources.db inherited from prior runs) hits SQLITE_ERROR: no such
column: t.group_name on /api/streams because lib/database.ts
initializeDatabase() creates the teams table with only
(team_id, team_name), but the runtime route SELECT joins on
t.group_name. The columns were added later via standalone migration
scripts (addGroupNameToTeams.ts, addGroupUuidColumn.ts) that aren't
auto-run on cold start.

Event-day risk: if a hot-spare laptop is provisioned at the venue,
this foot-gun fires on first boot.

Phase 0.8 (0.25 d, runs alongside Phase 0.7 — no shared surface):
  0.8.1  Fold group_name + group_uuid into the CREATE TABLE
  0.8.2  Array.isArray guard in app/page.tsx:80 unwrap path
  0.8.3  Jest test asserting schema covers every runtime SELECT col

Day-math updated: +0.25d → total nominal ~29.80 d; honest slack
narrows to +0.20 to +1.20 d (still positive).
deco scheduled this pull request to auto merge when all checks succeed 2026-05-20 22:02:13 +03:00
deco merged commit 2a9055713d into main 2026-05-20 22:03:51 +03:00
deco deleted branch plan/phase-0.8-schema-bootstrap 2026-05-20 22:03:51 +03:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
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
deco/cuesheet!20
No description provided.