Files
hyungi_document_server/migrations/146_documents_has_suggestion_idx.sql
T
Hyungi Ahn aceb54e586 fix(migrations): 143 asyncpg multi-statement 분리
asyncpg prepared statement 는 single-command 만 지원 (core/database.py
exec_driver_sql 경로). §1 의 143_category.sql 이 4 statement (TYPE +
ALTER + INDEX×2) 였어서 fastapi 부팅 시 asyncpg.PostgresSyntaxError
"cannot insert multiple commands into a prepared statement" 로 실패
→ 컨테이너 restart 루프.

143 을 4 개 파일로 분리:
  143: CREATE TYPE doc_category
  144: ALTER TABLE documents ADD category / ai_suggestion
  145: CREATE INDEX idx_documents_category
  146: CREATE INDEX idx_documents_has_suggestion (partial)

DB 상태는 깨끗 (migration 143 이 부분 적용 안 됨 — asyncpg 가 batch
자체를 reject). schema_migrations 에 143 도 미기록이라 재실행 안전.

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

10 lines
340 B
SQL

-- 146_documents_has_suggestion_idx.sql
-- Section 1: 승인 대기 제안 partial index (4/4)
-- plan: luminous-sprouting-hamster.md §1
--
-- 승인 UI 가 hit 하는 SELECT ... WHERE ai_suggestion IS NOT NULL 용 partial idx.
CREATE INDEX IF NOT EXISTS idx_documents_has_suggestion
ON documents(id)
WHERE ai_suggestion IS NOT NULL;