fix(db): candidate_source 컬럼 VARCHAR(30)→(100) 확장 (V031) #84

병합
htlee fix/candidate-source-length 에서 develop 로 2 commits 를 머지했습니다 2026-04-17 11:53:09 +09:00
Showing only changes of commit 0f4a9cb7d6 - Show all commits

파일 보기

@ -0,0 +1,20 @@
-- V031: gear_group_parent_candidate_snapshots.candidate_source VARCHAR(30) → VARCHAR(100)
--
-- 원인: prediction/algorithms/gear_parent_inference.py 의 _rank_candidates 가
-- candidate_source = ','.join(sorted(meta['sources'])) (line 875)
-- 로 여러 source 라벨(CORRELATION / EPISODE / LABEL / LINEAGE / MATCH 등) 을 쉼표로
-- join 해 저장한다. 모든 source 가 맞춰지면 약 39자(5개 라벨 + 쉼표) 에 달해
-- VARCHAR(30) 를 초과하며 psycopg2.errors.StringDataRightTruncation 을 유발.
--
-- 영향: prediction 사이클의 gear_correlation 스테이지에서 `_insert_candidate_snapshots`
-- 실패 → `gear_group_parent_candidate_snapshots` 테이블 갱신 전체 스킵.
-- Phase 0-1 의 사이클 스테이지 에러 격리 덕분에 후속 스테이지(pair_detection /
-- per-vessel analysis / upsert_results / 출력 모듈들)는 정상 완주.
--
-- 대안 검토:
-- (A) VARCHAR(100) — 여유치. 채택.
-- (B) TEXT — 제약 없음. 컬럼 의미가 "짧은 라벨 집합" 이라 VARCHAR 가 자연스러움.
-- (C) 코드에서 [:30] trim — 의미 손실(source 목록 절단). 부적합.
ALTER TABLE kcg.gear_group_parent_candidate_snapshots
ALTER COLUMN candidate_source TYPE VARCHAR(100);