mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 13:22:14 +00:00
0440 adds its columns with ADD COLUMN IF NOT EXISTS like 0424 and 0432; a structural test holds every migration from 0422 on to that form. 0430 clears insights_cached_at where no sealed payload is left, so the nightly pregenerate refills an account whose only copy was the readable column instead of keeping an empty card fresh. The deploy runbook notes that 0430 drops a users column: an old process fails on its next full user read, so stop before starting rather than running old and new side by side.
25 lines
1.2 KiB
SQL
25 lines
1.2 KiB
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";
|
|
|
|
-- A row whose only copy of the payload was the readable one now holds no
|
|
-- cached text at all, while its stamp still says the cache is fresh. Clear the
|
|
-- stamp so the nightly pregenerate picks the account up again instead of
|
|
-- waiting out the staleness window with an empty card.
|
|
UPDATE "users"
|
|
SET "insights_cached_at" = NULL
|
|
WHERE "insights_cached_text_encrypted" IS NULL
|
|
AND "insights_cached_at" IS NOT NULL;
|