Files
HealthLog/prisma/migrations/0430_drop_insights_cached_text/migration.sql
T
Marc-André Bombeck 9941db1549 refactor(insights): drop the readable cached-text column
Every write has gone to insights_cached_text_encrypted since 0411, and
the boot-time free-text backfill sealed the rows written before it.
Migration 0430 drops insights_cached_text and the backfill index that
served it. A host that skipped the intervening releases loses only a
cache of model output; the next warm writes a fresh, sealed payload.

The cipher module now reads and writes the sealed column only, the
backfill job loses its insights step, and consent withdrawal, the wipe
plan, the backup plan and the session projection follow the schema.
Backups never carried the column, and restore ignores unknown account
settings; a round-trip test now proves an old backup naming the field
still restores cleanly. The access guard pins exact counts for where
the sealed name may appear. Fixtures, the demo seed and the demo
migration script seed the sealed column instead of plaintext.
2026-10-21 19:24:21 +02:00

16 lines
821 B
SQL

-- Drop the readable copy of the cached AI insights payload.
--
-- Since 0411 every write goes to `insights_cached_text_encrypted` and leaves
-- `insights_cached_text` NULL, and the boot-time free-text encryption backfill
-- sealed the rows written before. Nothing reads the readable column any more.
--
-- A host that skipped the releases between 0411 and this one may still hold a
-- readable payload the backfill never reached. It is a cache of model output,
-- not a record: the next nightly or on-demand warm writes a fresh, sealed one.
-- Dropping it is the safe direction; keeping it would leave health text in the
-- clear on exactly the hosts that upgraded the longest way round.
DROP INDEX IF EXISTS "users_insights_cached_text_backfill_idx";
ALTER TABLE "users" DROP COLUMN IF EXISTS "insights_cached_text";