From f09a8f56a9edbfa754d95ff5ec8f2714461d3ec9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 27 Apr 2026 14:39:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20test=5Fschema=20=E5=8A=A0=20P2.1=20f?= =?UTF-8?q?usion=20=E6=AC=84=E4=BD=8D=20=E2=80=94=20=E8=A7=A3=20CI=201162-?= =?UTF-8?q?1172=20=E9=98=BB=E5=A1=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Production PG migration 已上線(commit c58bdd0c),但 CI 用獨立 docker pgvector test container(pg-test-b5),由 setup_test_schema.sql 初始化 → 無 fusion 欄位 → test_b5_core_flows.py 整合測試失敗於 composite_score column does not exist。 修法:把 P2.1 ALTER TABLE 加入 setup_test_schema.sql(idempotent IF NOT EXISTS) 新增(對齊 production p2_decision_fusion_columns.sql): - composite_score REAL - complexity_tier VARCHAR(16) + CHECK ('low','medium','high','critical') - decision_fusion_details JSONB partial index 不需要在 test schema(B5 整合測試不依賴 index)。 DO $$ block 處理 CHECK constraint 因 PG 不支援 ADD CONSTRAINT IF NOT EXISTS。 Co-Authored-By: Claude Opus 4.7 (1M context) --- .../tests/integration/setup_test_schema.sql | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/apps/api/tests/integration/setup_test_schema.sql b/apps/api/tests/integration/setup_test_schema.sql index 3f4495c0..8cc42765 100644 --- a/apps/api/tests/integration/setup_test_schema.sql +++ b/apps/api/tests/integration/setup_test_schema.sql @@ -77,6 +77,24 @@ CREATE TABLE IF NOT EXISTS approval_records ( resolved_at TIMESTAMPTZ ); +-- 2026-04-27 P2.1 DecisionFusion 欄位(對齊 p2_decision_fusion_columns.sql 已上 production) +-- IF NOT EXISTS 形式 idempotent,重跑安全 +ALTER TABLE approval_records + ADD COLUMN IF NOT EXISTS composite_score REAL, + ADD COLUMN IF NOT EXISTS complexity_tier VARCHAR(16), + ADD COLUMN IF NOT EXISTS decision_fusion_details JSONB; + +DO $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'chk_complexity_tier') THEN + ALTER TABLE approval_records + ADD CONSTRAINT chk_complexity_tier CHECK ( + complexity_tier IS NULL + OR complexity_tier IN ('low','medium','high','critical') + ); + END IF; +END $$; + CREATE TABLE IF NOT EXISTS knowledge_entries ( id VARCHAR(36) PRIMARY KEY, title VARCHAR NOT NULL,