36352-vm/db/migrations/007_create_student_exams_table.sql
Flatlogic Bot 93f530e4f6 t7
2025-12-07 19:58:10 +00:00

12 lines
534 B
SQL

CREATE TABLE IF NOT EXISTS student_exams (
id INT AUTO_INCREMENT PRIMARY KEY,
exam_id INT NOT NULL,
student_id INT NOT NULL,
status ENUM('assigned', 'in-progress', 'completed') DEFAULT 'assigned',
score INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (exam_id) REFERENCES exams(id) ON DELETE CASCADE,
FOREIGN KEY (student_id) REFERENCES users(id) ON DELETE CASCADE,
UNIQUE KEY (exam_id, student_id)
);