b46a75758b
Document Server에 Memos 앱 대체 기능 내장. 메모를 documents 테이블의 file_type='note' 레코드로 관리하여 기존 AI 파이프라인(classify/embed/ chunk/search/ask) 재활용. Backend: - migration 105: source_channel 'memo', file_path NULL 허용, user_tags/pinned/ask_includable 컬럼, 메모 인덱스 - api/memos.py: CRUD 7개 엔드포인트 + #태그 파싱 + stale AI 초기화 + 큐 pending 중복 방지 - queue_consumer: note extract/preview skip - documents API: file_path NULL 가드, 목록에서 메모 제외 - search /ask: ask_includable=false 문서 evidence 제외 Frontend: - /memos 타임라인 페이지 (빠른 입력 + 피드 + 인라인 편집 + 태그 필터) - QuickMemoButton FAB (Ctrl+M, 모든 페이지) - Sidebar 메모 링크 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
29 lines
1.3 KiB
SQL
29 lines
1.3 KiB
SQL
-- 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;
|