1.9 KiB
1.9 KiB
Database Schema Changelog
v1.1.0 - Exam Structure & Performance Optimization
Date: 2025-12-29
Migration ID: 0001_flawless_texas_twister
Author: Principal Database Architect
1. Summary
This release introduces support for hierarchical exam structures (Sectioning/Grouping) and optimizes database constraint naming for better compatibility with MySQL environments.
2. Changes
2.1 Table: exams
- Action:
ADD COLUMN - Field:
structure(JSON) - Reason: To support nested exam layouts (e.g., "Part I: Listening", "Section A").
- Architecture Note: This JSON field is strictly for Presentation Layer ordering and grouping. The
exam_questionstable remains the Source of Truth for relational integrity and scoring logic. - Schema Definition:
type ExamStructure = Array< | { type: 'group', title: string, children: ExamStructure } | { type: 'question', questionId: string, score: number } >
- Architecture Note: This JSON field is strictly for Presentation Layer ordering and grouping. The
2.2 Table: questions_to_knowledge_points
- Action:
RENAME FOREIGN KEY - Details:
- Old:
questions_to_knowledge_points_question_id_questions_id_fk-> New:q_kp_qid_fk - Old:
questions_to_knowledge_points_knowledge_point_id_knowledge_points_id_fk-> New:q_kp_kpid_fk
- Old:
- Reason: Previous names exceeded MySQL's 64-character identifier limit, causing potential migration failures in production environments.
3. Migration Strategy
- Up: Run standard Drizzle migration. The script includes
ALTER TABLE ... DROP FOREIGN KEYfollowed byADD CONSTRAINT. - Down: Revert
structurecolumn. Note that FK names can be kept short as they are implementation details.
4. Impact Analysis
- Performance: Negligible. JSON parsing is done client-side or at application layer.
- Data Integrity: High. Existing data is unaffected. New
structurefield defaults toNULL.