waxwing/app/db/migrations/005_knowledge_facts.sql
pyr0ball 5f5cb99db6 feat: bootstrap Waxwing Phase 1 scaffold
Plant registry, grow event calendar, and gardening knowledge base
populated via cf-harvest ingest endpoint. All 23 tests passing.

Stack:
- FastAPI + SQLite (cf-core migrations) on port 8522
- Vue 3 + Vite + Pinia SPA on port 8521
- 5 SQL migrations: locations → plants → grow_events, knowledge_sources → knowledge_facts
- Earthy green theme (--color-primary: #4a7c59) matching CF theme system

Knowledge ingest contract:
- POST /api/v1/knowledge/ingest — idempotent on fact_hash (sha256 of type+payload+video_path)
- 8 fact types: companion_planting, soil_amendment, propagation, pest_diagnosis,
  harvest_timing, instruction, medicinal, history_context
- Partial batch failure: malformed facts collected in rejected[], valid facts inserted
- Re-ingesting same video batch: facts_skipped_duplicate > 0, no duplicates

Wired views: RegistryView (plant CRUD), KnowledgeView (facts + type filter chips)
Stub views: CalendarView, SettingsView
2026-06-10 00:03:41 -07:00

24 lines
1.1 KiB
SQL

-- Migration 005: structured facts extracted by cf-harvest
-- payload stores the type-specific JSON verbatim — no field flattening.
-- fact_hash deduplicates identical facts across re-ingests.
CREATE TABLE IF NOT EXISTS knowledge_facts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
source_id INTEGER NOT NULL REFERENCES knowledge_sources(id) ON DELETE CASCADE,
fact_type TEXT NOT NULL
CHECK (fact_type IN (
'companion_planting', 'soil_amendment', 'propagation',
'pest_diagnosis', 'harvest_timing', 'instruction',
'medicinal', 'history_context'
)),
subject TEXT,
payload TEXT NOT NULL,
presenter TEXT,
confidence REAL,
fact_hash TEXT NOT NULL UNIQUE,
created_at TEXT NOT NULL DEFAULT (datetime('now'))
);
CREATE INDEX IF NOT EXISTS idx_knowledge_facts_type ON knowledge_facts (fact_type);
CREATE INDEX IF NOT EXISTS idx_knowledge_facts_subject ON knowledge_facts (subject);
CREATE INDEX IF NOT EXISTS idx_knowledge_facts_source_id ON knowledge_facts (source_id);