Files
HealthLog/prisma/migrations/0231_documents_auto_ai_read/migration.sql
T
Marc-André Bombeck 813dc2547b feat(documents): add per-user automatic AI reading opt-in
Add the documentsAutoAiRead per-user Boolean (migration 0231, default
false) that authorises ambient AI reading of uploaded vault documents.
OFF by default keeps the vault local-first for every self-hoster.

- schema column + migration 0231_documents_auto_ai_read
- documentAutoReadEnabled(userId) read helper
- GET/PATCH /api/auth/me/documents-auto-ai-read toggle route; the ON
  write mints an ai_full consent receipt for the audit trail
- the document consent gate short-circuits an external pick when the
  toggle is ON; a local pick stays ungated and OFF still requires a
  receipt for any external egress
2026-07-09 10:32:59 +02:00

18 lines
932 B
SQL

-- Automatic AI reading of uploaded vault documents (per-user opt-in).
--
-- One additive, defaulted column on `users`. OFF by default: the document vault
-- stays local-first — a freshly uploaded document is only read by an external AI
-- provider when the user explicitly taps a per-document action (which still
-- requires an active consent receipt). When `true`, the auto-index-on-upload job
-- may read a new document through the user's configured external provider with
-- no per-document tap; flipping the toggle on is itself the standing consent
-- (the write that sets it also mints an `ai_full` consent receipt for the audit
-- trail).
--
-- The default `false` backfills every existing row onto the current behaviour
-- (local-first, per-document-explicit, consent-required), so this is a no-op for
-- anyone who never opts in.
ALTER TABLE "users"
ADD COLUMN "documents_auto_ai_read" BOOLEAN NOT NULL DEFAULT false;