diff --git a/migrations/105_memo_support.sql b/migrations/105_memo_support.sql index 3e1da89..8f54ff4 100644 --- a/migrations/105_memo_support.sql +++ b/migrations/105_memo_support.sql @@ -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' diff --git a/migrations/106_memo_file_path_nullable.sql b/migrations/106_memo_file_path_nullable.sql new file mode 100644 index 0000000..064e078 --- /dev/null +++ b/migrations/106_memo_file_path_nullable.sql @@ -0,0 +1,2 @@ +-- 106: file_path NOT NULL 제거 (메모는 파일 없는 문서) +ALTER TABLE documents ALTER COLUMN file_path DROP NOT NULL diff --git a/migrations/107_memo_file_path_partial_unique.sql b/migrations/107_memo_file_path_partial_unique.sql new file mode 100644 index 0000000..4d41b62 --- /dev/null +++ b/migrations/107_memo_file_path_partial_unique.sql @@ -0,0 +1,2 @@ +-- 107: file_path UNIQUE → partial unique (NULL 허용, 값 있으면 유니크) +DROP INDEX IF EXISTS documents_file_path_key diff --git a/migrations/108_memo_file_path_partial_unique_idx.sql b/migrations/108_memo_file_path_partial_unique_idx.sql new file mode 100644 index 0000000..12d2d07 --- /dev/null +++ b/migrations/108_memo_file_path_partial_unique_idx.sql @@ -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 diff --git a/migrations/109_memo_columns.sql b/migrations/109_memo_columns.sql new file mode 100644 index 0000000..e455419 --- /dev/null +++ b/migrations/109_memo_columns.sql @@ -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 diff --git a/migrations/110_memo_pinned.sql b/migrations/110_memo_pinned.sql new file mode 100644 index 0000000..c6b1cce --- /dev/null +++ b/migrations/110_memo_pinned.sql @@ -0,0 +1,2 @@ +-- 110: 메모 핀 고정 컬럼 +ALTER TABLE documents ADD COLUMN IF NOT EXISTS pinned BOOLEAN DEFAULT false diff --git a/migrations/111_memo_ask_includable.sql b/migrations/111_memo_ask_includable.sql new file mode 100644 index 0000000..52ac055 --- /dev/null +++ b/migrations/111_memo_ask_includable.sql @@ -0,0 +1,2 @@ +-- 111: /ask 합성 포함 여부 (false면 검색은 되지만 /ask evidence에서 제외) +ALTER TABLE documents ADD COLUMN IF NOT EXISTS ask_includable BOOLEAN DEFAULT true diff --git a/migrations/112_memo_notes_index.sql b/migrations/112_memo_notes_index.sql new file mode 100644 index 0000000..9cf1a45 --- /dev/null +++ b/migrations/112_memo_notes_index.sql @@ -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