diff --git a/backend/src/db/migrations/058_exam_topics_textbook_fix.sql b/backend/src/db/migrations/058_exam_topics_textbook_fix.sql new file mode 100644 index 0000000..e7626d1 --- /dev/null +++ b/backend/src/db/migrations/058_exam_topics_textbook_fix.sql @@ -0,0 +1,73 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 058: Fix exam_topics textbook_slug/paragraph (subtopic-level fallback) +-- +-- Migration 028 set coarse fallback values. This migration corrects them +-- to align with the detailed per-subtopic maps from PLAN.md. +-- These values act as fallback when a task has no task-level textbook_slug +-- (e.g. theory-statements or newly added tasks not yet classified). +-- ═══════════════════════════════════════════════════════════════ + +-- ── Algebra subtopics (fix / improve) ────────────────────────── + +-- alg-numbers: rational numbers are in math-6-ch4 (better than algebra-9 hub) +UPDATE exam_topics SET textbook_slug = 'math-6-ch4', textbook_paragraph = NULL + WHERE slug = 'alg-numbers' AND exam_key = 'math9'; + +-- alg-arithmetic: basic arithmetic → math-6-ch1 (decimals, most common 5-6 topic) +UPDATE exam_topics SET textbook_slug = 'math-6-ch1', textbook_paragraph = NULL + WHERE slug = 'alg-arithmetic' AND exam_key = 'math9'; + +-- alg-powers: primary is natural exponent → algebra-7-ch1 §1 +UPDATE exam_topics SET textbook_slug = 'algebra-7-ch1', textbook_paragraph = 1 + WHERE slug = 'alg-powers' AND exam_key = 'math9'; + +-- alg-expressions: primary → algebra-9-ch1 §5 (rational expression transform) +-- (028 already set this correctly) + +-- alg-polynomials: primary → algebra-7-ch2 §14 (factoring, most tested) +UPDATE exam_topics SET textbook_slug = 'algebra-7-ch2', textbook_paragraph = 14 + WHERE slug = 'alg-polynomials' AND exam_key = 'math9'; + +-- alg-fractions: primary → algebra-9-ch1 §3 (add/subtract rational fractions) +-- (028 already set §3; keep it) + +-- alg-equations: primary → algebra-8-ch2 §8 (quadratic by discriminant, most common) +-- (028 had §10 from algebra-9-ch3 which is drobno-rational — fix to quadratic) +UPDATE exam_topics SET textbook_slug = 'algebra-8-ch2', textbook_paragraph = 8 + WHERE slug = 'alg-equations' AND exam_key = 'math9'; + +-- alg-inequalities: primary → algebra-8-ch3 §17 (quadratic inequalities, method of intervals) +-- (028 already set §13; fix to §17 which is the most common exam topic) +UPDATE exam_topics SET textbook_slug = 'algebra-8-ch3', textbook_paragraph = 17 + WHERE slug = 'alg-inequalities' AND exam_key = 'math9'; + +-- alg-functions: primary → algebra-9-ch2 §6 (function of numeric argument) +-- (028 already set §6; keep it) + +-- alg-progressions: primary → algebra-9-ch4 §15 (arithmetic progression) +-- (028 already set §15; keep it) + +-- alg-word-problems: primary → math-6-ch2 (percentages — most common type) +UPDATE exam_topics SET textbook_slug = 'math-6-ch2', textbook_paragraph = NULL + WHERE slug = 'alg-word-problems' AND exam_key = 'math9'; + +-- ── Geometry subtopics (fix / improve) ────────────────────────── + +-- geom-triangles: primary → geometry-9-ch1 §1 (trig in right triangle, most tested) +-- (028 had §1 of geometry-9-ch1; keep it) + +-- geom-quadrilaterals: primary → geometry-8-ch1 §4 (parallelogram, most common) +-- (028 had §9 of geometry-9-ch2 — too specific; fix to general parallelogram) +UPDATE exam_topics SET textbook_slug = 'geometry-8-ch1', textbook_paragraph = 4 + WHERE slug = 'geom-quadrilaterals' AND exam_key = 'math9'; + +-- geom-circle: primary → geometry-8-ch4 §8 (central angle / inscribed angle) +-- (028 had §7 of geometry-9-ch2; fix to geometry-8-ch4 §8) +UPDATE exam_topics SET textbook_slug = 'geometry-8-ch4', textbook_paragraph = 8 + WHERE slug = 'geom-circle' AND exam_key = 'math9'; + +-- geom-coordinates: primary → algebra-9-ch3 §12 (circle equation) +-- (028 already set §12; keep it) + +-- theory-statements: leave NULL — no single textbook home +-- (028 already left NULL; keep it)