Files
hyungi_document_server/migrations/153_analyze_events_shadow.sql
Hyungi Ahn c9e8dd0ba1 fix(db): split migration 153 for asyncpg single-statement limit
asyncpg exec_driver_sql 이 prepared statement 로 multiple commands 를
허용하지 않아 배포 시 PostgresSyntaxError: cannot insert multiple commands
into a prepared statement 로 init_db() 실패.

153 를 단일 ALTER TABLE (10 ADD COLUMN) 로 축소하고 2 partial index 를
154/155 로 분리:

- 153_analyze_events_shadow.sql: ALTER TABLE ADD COLUMN (단일 statement)
- 154_analyze_events_shadow_idx_ts.sql: idx_analyze_events_shadow_ts
- 155_analyze_events_policy_violation_idx.sql: idx_analyze_events_policy_violation

배포 test: GPU fastapi 컨테이너 재빌드 후 init_db 가 153/154/155 세 파일을
순차 적용 (asyncpg prepared statement 1 파일 1 문).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 09:38:40 +09:00

24 lines
1.2 KiB
SQL

-- 153_analyze_events_shadow.sql
-- AI Policy Layer (PR-A) — shadow 관측용 컬럼 추가. 아무도 쓰지 않음.
-- PR-B 가 DBShadowLogger 구현 후 writer 추가 예정.
--
-- plan: ~/.claude/plans/wise-gliding-hippo.md
-- axis 원칙: feedback_category_vs_ai_domain_axis.md (subject_domain 은 정책 축,
-- documents.category 매칭 키로 쓰지 않음)
--
-- 주의: _run_migrations 는 asyncpg exec_driver_sql 로 단일 prepared statement 실행 —
-- 한 파일에 단일 SQL statement 만 허용 (multi-statement 시 PostgresSyntaxError).
-- index 는 migrations 154/155 로 분리.
ALTER TABLE analyze_events
ADD COLUMN IF NOT EXISTS subject_domain TEXT,
ADD COLUMN IF NOT EXISTS risk_flags TEXT[],
ADD COLUMN IF NOT EXISTS high_impact_task BOOLEAN,
ADD COLUMN IF NOT EXISTS escalated_to_26b BOOLEAN,
ADD COLUMN IF NOT EXISTS escalation_reasons TEXT[],
ADD COLUMN IF NOT EXISTS confidence REAL,
ADD COLUMN IF NOT EXISTS policy_violation BOOLEAN,
ADD COLUMN IF NOT EXISTS policy_violation_ids TEXT[],
ADD COLUMN IF NOT EXISTS shadow_would_route_to TEXT,
ADD COLUMN IF NOT EXISTS policy_version TEXT;