Files
hyungi_document_server/migrations/282_document_chunks_hier_columns.sql
T
hyungi 7971e69e3e feat(search): hier decomposition schema + corpus_chunks view (Hier-Decomp-1 c1)
PR-DocSrv-Hierarchical-Decomposition-1 c1 (G1).
- migration 282: document_chunks ADD parent_id/level/node_type/is_leaf/in_corpus
  (단일 statement ALTER, additive, IF NOT EXISTS). legacy 행 = in_corpus=true/is_leaf=false 기본값.
- migration 283: corpus_chunks 뷰 (WHERE in_corpus=true) = 검색 코퍼스 단일 choke point.
  c2 에서 retrieval 을 이 뷰로 rewire. node_type 은 hint, replace 는 is_leaf 사용.

검증: schema_migrations 282/283, 30952 행 in_corpus=true 보존, corpus_chunks 30952,
/health 200, restarts=0. dry-run(BEGIN/ROLLBACK) 선검증 후 적용.

plan: hierarchical-decomposition-tiered-nesting-marmot.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 12:47:41 +00:00

15 lines
1.1 KiB
SQL

-- PR-DocSrv-Hierarchical-Decomposition-1 (c1: schema)
-- 계층 분해 트리 컬럼 (단일 statement = runner single-statement 제약 OK, 다중 ADD COLUMN action).
-- parent_id : 트리 부모. DB FK 미설정(cascade 모호성 + single-statement 회피). 무결성은 builder(G2)+replace(G5) 검증 쿼리로 강제.
-- level : authoritative depth (0=root/doc, 증가).
-- node_type : nullable hint(chapter/section/clause...). retrieval/replace 활성 조건에 절대 미사용.
-- is_leaf : authoritative leaf 마커 (replace predicate 가 이것만 신뢰).
-- in_corpus : 검색 코퍼스 편입 여부. 기본 true → 기존 legacy 행은 검색 유지. 신규 hier 행은 false 로 적재.
-- plan: ~/.claude/plans/hierarchical-decomposition-tiered-nesting-marmot.md
ALTER TABLE document_chunks
ADD COLUMN IF NOT EXISTS parent_id bigint NULL,
ADD COLUMN IF NOT EXISTS level smallint NULL,
ADD COLUMN IF NOT EXISTS node_type text NULL,
ADD COLUMN IF NOT EXISTS is_leaf boolean NOT NULL DEFAULT false,
ADD COLUMN IF NOT EXISTS in_corpus boolean NOT NULL DEFAULT true;