fix(memos): migration을 개별 파일로 분리 (asyncpg multi-statement 미지원)
asyncpg prepared statement가 multi-command를 지원하지 않아 시작 실패. 105 단일 파일을 105-112 개별 statement로 분리. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,28 +1,2 @@
|
||||
-- 105: 메모(note) 기능 지원
|
||||
-- 메모 = file_type='note'인 document (파일 없는 문서)
|
||||
-- file_hash는 note에서 content SHA-256 (파일 해시가 아닌 본문 버전 해시)
|
||||
|
||||
-- source_channel enum에 'memo' 추가 (유입 경로: 내장 메모 UI)
|
||||
ALTER TYPE source_channel ADD VALUE IF NOT EXISTS 'memo';
|
||||
|
||||
-- file_path: NOT NULL 제거 (메모는 파일 없음)
|
||||
ALTER TABLE documents ALTER COLUMN file_path DROP NOT NULL;
|
||||
|
||||
-- file_path: 기존 UNIQUE → partial unique (NULL 허용, 값 있으면 유니크)
|
||||
DROP INDEX IF EXISTS documents_file_path_key;
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uq_documents_file_path
|
||||
ON documents(file_path) WHERE file_path IS NOT NULL;
|
||||
|
||||
-- user_tags: 사용자 수동 태그 (ai_tags와 분리, list[str])
|
||||
ALTER TABLE documents ADD COLUMN IF NOT EXISTS user_tags JSONB DEFAULT '[]'::jsonb;
|
||||
|
||||
-- pinned: 메모 핀 고정
|
||||
ALTER TABLE documents ADD COLUMN IF NOT EXISTS pinned BOOLEAN DEFAULT false;
|
||||
|
||||
-- ask_includable: /ask 합성 포함 여부 (false면 검색은 되지만 /ask evidence에서 제외)
|
||||
ALTER TABLE documents ADD COLUMN IF NOT EXISTS ask_includable BOOLEAN DEFAULT true;
|
||||
|
||||
-- 메모 목록 최적화 인덱스 (핀 우선 + 최신순)
|
||||
CREATE INDEX IF NOT EXISTS idx_documents_notes
|
||||
ON documents(pinned DESC, created_at DESC)
|
||||
WHERE file_type = 'note' AND deleted_at IS NULL;
|
||||
-- 105: source_channel enum에 'memo' 추가 (메모 유입 경로)
|
||||
ALTER TYPE source_channel ADD VALUE IF NOT EXISTS 'memo'
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
-- 106: file_path NOT NULL 제거 (메모는 파일 없는 문서)
|
||||
ALTER TABLE documents ALTER COLUMN file_path DROP NOT NULL
|
||||
@@ -0,0 +1,2 @@
|
||||
-- 107: file_path UNIQUE → partial unique (NULL 허용, 값 있으면 유니크)
|
||||
DROP INDEX IF EXISTS documents_file_path_key
|
||||
@@ -0,0 +1,2 @@
|
||||
-- 108: file_path partial unique 인덱스 생성
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uq_documents_file_path ON documents(file_path) WHERE file_path IS NOT NULL
|
||||
@@ -0,0 +1,3 @@
|
||||
-- 109: 메모 지원 컬럼 추가 (user_tags, pinned, ask_includable)
|
||||
-- file_hash는 note에서 content SHA-256 (파일 해시가 아닌 본문 버전 해시)
|
||||
ALTER TABLE documents ADD COLUMN IF NOT EXISTS user_tags JSONB DEFAULT '[]'::jsonb
|
||||
@@ -0,0 +1,2 @@
|
||||
-- 110: 메모 핀 고정 컬럼
|
||||
ALTER TABLE documents ADD COLUMN IF NOT EXISTS pinned BOOLEAN DEFAULT false
|
||||
@@ -0,0 +1,2 @@
|
||||
-- 111: /ask 합성 포함 여부 (false면 검색은 되지만 /ask evidence에서 제외)
|
||||
ALTER TABLE documents ADD COLUMN IF NOT EXISTS ask_includable BOOLEAN DEFAULT true
|
||||
@@ -0,0 +1,2 @@
|
||||
-- 112: 메모 목록 최적화 인덱스 (핀 우선 + 최신순)
|
||||
CREATE INDEX IF NOT EXISTS idx_documents_notes ON documents(pinned DESC, created_at DESC) WHERE file_type = 'note' AND deleted_at IS NULL
|
||||
Reference in New Issue
Block a user