From 337bcb912e4b78eb79b8994f714424610cf3ae72 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 1 May 2026 11:08:21 +0800 Subject: [PATCH] fix(db): tolerate knowledge enum owner mismatch --- .../phase25_knowledge_enum_names.sql | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/apps/api/migrations/phase25_knowledge_enum_names.sql b/apps/api/migrations/phase25_knowledge_enum_names.sql index c28aca3e..efca7e85 100644 --- a/apps/api/migrations/phase25_knowledge_enum_names.sql +++ b/apps/api/migrations/phase25_knowledge_enum_names.sql @@ -1,6 +1,23 @@ --- Phase 25 Knowledge Auto-Harvesting enum compatibility +-- Phase 25 Knowledge Auto-Harvesting enum compatibility. -- SQLAlchemy stores Enum names (AUTO_RUNBOOK / ANTI_PATTERN) for EntryType. -- Older production DBs only had lowercase labels from the first migration. +-- +-- Note: some CI migrator roles do not own enum types. Production was patched +-- manually on 2026-05-01; this migration is kept as the durable schema record +-- and tolerates insufficient_privilege so the migration workflow can continue. -ALTER TYPE entrytype ADD VALUE IF NOT EXISTS 'AUTO_RUNBOOK'; -ALTER TYPE entrytype ADD VALUE IF NOT EXISTS 'ANTI_PATTERN'; +DO $$ +BEGIN + ALTER TYPE entrytype ADD VALUE IF NOT EXISTS 'AUTO_RUNBOOK'; +EXCEPTION + WHEN insufficient_privilege THEN + RAISE NOTICE 'Skipping entrytype AUTO_RUNBOOK; migrator does not own enum type'; +END $$; + +DO $$ +BEGIN + ALTER TYPE entrytype ADD VALUE IF NOT EXISTS 'ANTI_PATTERN'; +EXCEPTION + WHEN insufficient_privilege THEN + RAISE NOTICE 'Skipping entrytype ANTI_PATTERN; migrator does not own enum type'; +END $$;