-- Custom migration (audit P14): extend lz4 TOAST compression to the two heavy
-- jsonb columns left out of 0024 — `site_audits.results` (the biggest, fully
-- rewritten on every audit: ~156 items) and `keywords.gsc`. Same rationale as
-- 0024_keywords_toast_lz4: lz4 decompresses near-free vs pglz and usually
-- stores smaller. Metadata-only DDL — existing rows are NOT recompressed, only
-- new writes take lz4 (site_audits.results migrates on the next re-audit).
--
-- lz4 requires Postgres compiled --with-lz4 (PG >= 14); the official Docker
-- images (prod) are. On a build without it the ALTER raises
-- feature_not_supported, so each table is guarded to degrade to a no-op NOTICE
-- instead of hard-failing the migration chain.
DO $$
BEGIN
  ALTER TABLE site_audits ALTER COLUMN results SET COMPRESSION lz4;
  ALTER TABLE keywords ALTER COLUMN gsc SET COMPRESSION lz4;
EXCEPTION
  WHEN feature_not_supported THEN
    RAISE NOTICE 'lz4 TOAST compression not supported by this Postgres build; keeping default (pglz). Rebuild --with-lz4 (or use the official Docker image) to enable.';
END $$;
