Files
hyungi_document_server/migrations/204_study_topic_subject_notes.sql
Hyungi Ahn d968b2d901 feat(study): 문제풀이 모드 개편 + 결과 분류 + 분야 설명 (PR-9)
- 라벨 "복습 시작" → "문제풀이"
- attempts.outcome 컬럼 + selected_choice nullable (correct/wrong/unsure)
- 풀이 중 정답·해설·AI·비슷한 문제 모두 비노출, 답 클릭 시 자동 진행
- "모르겠음" 5번째 옵션 추가
- 결과 화면 = 정답/틀린/모르겠음 3 카테고리 탭, 카드 클릭 expand
  - 틀린 → PR-3 AI 해설 (RAG)
  - 모르겠음 → 분야(subject+scope) 설명 AI 즉석 생성 + 캐시 (PR-9 신규)
- 분야 설명 RAG: 매핑 documents 청크 + 같은 분야 다른 문제·해설 → bge-reranker
- 마이그레이션 200~205 (single-statement, asyncpg 호환)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 15:58:35 +09:00

21 lines
1015 B
SQL

-- 204_study_topic_subject_notes.sql (5/6)
-- 분야 설명 캐시 (PR-9). (study_topic, subject, scope) 단위.
-- 사용자가 풀이 결과 화면에서 "모르겠음" 카드 클릭 시 AI 즉석 생성 + 캐시.
--
-- status 권장값: none/pending/ready/failed/stale (PR-3 ai_explanation_status 와 동일 패턴).
-- scope 는 NULL 대신 빈 문자열 default — UNIQUE 제약 단순화.
CREATE TABLE IF NOT EXISTS study_topic_subject_notes (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
study_topic_id BIGINT NOT NULL REFERENCES study_topics(id) ON DELETE CASCADE,
subject VARCHAR(120) NOT NULL,
scope VARCHAR(200) NOT NULL DEFAULT '',
content TEXT,
status VARCHAR(20) NOT NULL DEFAULT 'none',
generated_at TIMESTAMPTZ,
model VARCHAR(120),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);