13 lines
567 B
SQL
13 lines
567 B
SQL
-- Attendance migration
|
|
CREATE TABLE IF NOT EXISTS attendance (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
student_id INT NOT NULL,
|
|
class_id INT NOT NULL,
|
|
status ENUM('hadir', 'sakit', 'izin', 'alpa') NOT NULL DEFAULT 'alpa',
|
|
attendance_date DATE NOT NULL,
|
|
recorded_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (student_id) REFERENCES students(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (class_id) REFERENCES classes(id) ON DELETE CASCADE,
|
|
UNIQUE KEY unique_attendance (student_id, attendance_date)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|