Phase 1: data layer (SQLite, migrations, models, seed)

This commit is contained in:
prosolis
2026-06-25 20:25:14 -07:00
parent e72d48d64e
commit 9c98e97030
7 changed files with 403 additions and 7 deletions

View File

@@ -21,11 +21,12 @@ Multi-session build. **Source of truth for what's done and what's next.** Update
- [x] Dev workflow documented in README; `.env.example` added
- [x] Verified end-to-end: binary serves `/api/health` + embedded SPA + SPA fallback
### Phase 1 — Data layer
- [ ] SQLite (modernc) init + migrations (`internal/db/db.go`)
- [ ] Models: User, Document, Suggestion (`internal/db/models.go`)
- [ ] Seed hardcoded `local` user
- [ ] Schema includes `voice` in suggestions type CHECK
### Phase 1 — Data layer
- [x] SQLite (modernc) init + migrations (`internal/db/db.go`) — versioned `schema_migrations` runner, WAL + foreign keys, single writer conn
- [x] Models: User, Document, Suggestion (`internal/db/models.go`) — + type/status constants
- [x] Seed hardcoded `local` user (idempotent on startup)
- [x] Schema includes `voice` in suggestions type CHECK (full spec schema incl. plagiarism_reports, to avoid a later migration)
- [x] `db.Open` wired into `cmd/server/main.go`; `db_test.go` covers migrate/seed idempotency, CHECK constraint, FK cascade
### Phase 2 — Document CRUD + auto-save ← first "it works" milestone
- [ ] Doc handlers: list/create/get/update/delete (`internal/docs/handlers.go`)
@@ -70,3 +71,4 @@ Multi-session build. **Source of truth for what's done and what's next.** Update
## Session log
- 2026-06-25: Spec reviewed & amended (voice/grammar decoupled, ctx cap, routes, voice DB type, honey color, string-anchoring). Build plan created.
- 2026-06-25: **Phase 0 complete.** Go module + chi server, config loader, React/Vite/Tailwind-v4 scaffold with full design tokens, frontend embedded & served by the binary, verified end-to-end. Toolchain: Go 1.24.4, Node 22, npm 10. Next: **Phase 1 (data layer)** — SQLite via modernc, models, seed `local` user.
- 2026-06-25: **Phase 1 complete.** `internal/db` package: modernc.org/sqlite (pulled go toolchain → 1.25), `Open()` does mkdir + WAL/foreign-keys DSN + versioned migration runner + idempotent local-user seed. Models with type/status constants. Wired into `main.go`; tests pass (migrate/seed idempotency, CHECK reject, FK cascade). Verified server boots and writes `petal.db`. Next: **Phase 2 (document CRUD + auto-save)** — first "it works" milestone.