From d01617e2bc720b33b31636bfad20c4b52d96f203 Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Tue, 14 Apr 2026 15:30:06 +0900 Subject: [PATCH] =?UTF-8?q?fix(library):=20=EB=A7=88=EC=9D=B4=EA=B7=B8?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EC=85=98=20asyncpg=20multiple=20statement=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit asyncpg는 prepared statement에 여러 명령을 넣을 수 없음. CREATE TYPE + ALTER TABLE을 단일 DO $$ 블록으로 합침. Co-Authored-By: Claude Opus 4.6 (1M context) --- migrations/115_doc_purpose.sql | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/migrations/115_doc_purpose.sql b/migrations/115_doc_purpose.sql index 790369b..e7994ba 100644 --- a/migrations/115_doc_purpose.sql +++ b/migrations/115_doc_purpose.sql @@ -1,5 +1,10 @@ -- 문서 용도 구분: business(업무용) | knowledge(참조용) --- 기존 문서는 NULL → AI 재분류 시 점진 채움 --- 우선순위: 수동 수정 > 업로드 시 명시값 > AI 추론 -CREATE TYPE document_purpose AS ENUM ('business', 'knowledge'); -ALTER TABLE documents ADD COLUMN doc_purpose document_purpose; +DO $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'document_purpose') THEN + CREATE TYPE document_purpose AS ENUM ('business', 'knowledge'); + END IF; + IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name='documents' AND column_name='doc_purpose') THEN + ALTER TABLE documents ADD COLUMN doc_purpose document_purpose; + END IF; +END $$;