G1 — Design System: 14 UI primitives (Button, Card, Modal, Sheet, Input, Textarea, Select, EmptyState, LoadingShimmer, ConfirmDialog, WashiTape, Badge, Avatar, Tabs), PageTransition with Framer Motion, sun/moon CSS vars, Caveat font, /dev/components visual showcase. G2 — Memories Pipeline: R2 presigned uploads, Sharp thumbnail generation, LiteLLM vision captions + pgvector embeddings, CSS masonry gallery with infinite scroll, private toggle, semantic search fallback to ILIKE. G3 — Medical: dose log + correction audit trail, IAP vaccine bulk import, emergency escalation page, pediatrician phone in settings. G4 — AI Brain: keyword guardrail → LLM classifier → structured DB tool-use (7 tools) → memory search → general parenting handler; ai_usage table; 22-case medical bypass safety test suite. DB migrations: 0011_memories, 0012_medical_doses, 0013_ai_usage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
45 lines
1.5 KiB
SQL
45 lines
1.5 KiB
SQL
-- Enable pgvector if not already
|
|
CREATE EXTENSION IF NOT EXISTS vector;
|
|
|
|
-- Memories table (photos with vision metadata)
|
|
CREATE TABLE IF NOT EXISTS memories (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
family_id UUID NOT NULL,
|
|
child_id UUID,
|
|
title TEXT,
|
|
description TEXT,
|
|
taken_at TIMESTAMPTZ,
|
|
r2_key TEXT NOT NULL,
|
|
r2_thumbnail_key TEXT,
|
|
mime_type TEXT,
|
|
size_bytes INTEGER,
|
|
width INTEGER,
|
|
height INTEGER,
|
|
vision_caption TEXT,
|
|
vision_tags TEXT[],
|
|
vision_embedding VECTOR(1536),
|
|
is_private BOOLEAN NOT NULL DEFAULT FALSE,
|
|
processing_status TEXT NOT NULL DEFAULT 'uploading'
|
|
CHECK (processing_status IN ('uploading', 'processing', 'ready', 'failed')),
|
|
uploaded_by UUID,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS memories_family_idx ON memories (family_id);
|
|
CREATE INDEX IF NOT EXISTS memories_child_idx ON memories (child_id);
|
|
|
|
-- Attachments table (files linked to log entries, no vision)
|
|
CREATE TABLE IF NOT EXISTS attachments (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
family_id UUID NOT NULL,
|
|
log_entry_id UUID,
|
|
r2_key TEXT NOT NULL,
|
|
r2_thumbnail_key TEXT,
|
|
mime_type TEXT,
|
|
size_bytes INTEGER,
|
|
uploaded_by UUID,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS attachments_family_idx ON attachments (family_id);
|