-- ============================================ -- PastPaper Master — Question taxonomy fields -- Version: 003 -- Date: 2026-03-24 -- ============================================ -- A question needs multiple classification layers: -- 1) question_format: how the student interacts with it -- 2) topic_tags / topic_primary / analytics_topic: course knowledge taxonomy -- 3) skill_tags: what kind of thinking task the question requires ALTER TABLE paper_questions ADD COLUMN IF NOT EXISTS question_format TEXT CHECK ( question_format IN ( 'mc', 'true_false', 'fill_blank', 'short_answer', 'long_answer', 'coding' ) ), ADD COLUMN IF NOT EXISTS topic_primary TEXT, ADD COLUMN IF NOT EXISTS analytics_topic TEXT, ADD COLUMN IF NOT EXISTS topic_tags TEXT[], ADD COLUMN IF NOT EXISTS skill_tags TEXT[]; -- Keep the legacy topics column for backward compatibility for now. -- New analytics and retrieval code should gradually move to analytics_topic/topic_tags. CREATE INDEX IF NOT EXISTS idx_questions_question_format ON paper_questions(question_format); CREATE INDEX IF NOT EXISTS idx_questions_analytics_topic ON paper_questions(analytics_topic); CREATE INDEX IF NOT EXISTS idx_questions_topic_tags ON paper_questions USING GIN(topic_tags); CREATE INDEX IF NOT EXISTS idx_questions_skill_tags ON paper_questions USING GIN(skill_tags);