fix tests issues
Tests / PHPUnit (push) Failing after 1m16s

This commit is contained in:
root
2026-07-13 00:24:00 -04:00
parent 439a695727
commit a56aca4342
17 changed files with 349 additions and 40 deletions
@@ -8,10 +8,18 @@ class RemoveClassAssignmentSemester extends Migration
{
public function up()
{
if ($this->db->tableExists('teacher_class')) {
if ($this->db->tableExists('teacher_class') && $this->db->fieldExists('semester', 'teacher_class')) {
if ($this->indexExists('teacher_class', 'unique_teacher_assignment')) {
$this->db->query('ALTER TABLE `teacher_class` DROP INDEX `unique_teacher_assignment`');
}
$this->forge->dropColumn('teacher_class', 'semester');
$this->db->query(
'ALTER TABLE `teacher_class` ADD UNIQUE KEY `unique_teacher_assignment` (`teacher_id`, `class_section_id`, `school_year`)'
);
}
if ($this->db->tableExists('student_class')) {
if ($this->db->tableExists('student_class') && $this->db->fieldExists('semester', 'student_class')) {
$this->forge->dropColumn('student_class', 'semester');
}
}
@@ -39,4 +47,13 @@ class RemoveClassAssignmentSemester extends Migration
]);
}
}
private function indexExists(string $table, string $index): bool
{
$result = $this->db->query(
'SHOW INDEX FROM `' . str_replace('`', '``', $table) . '` WHERE Key_name = ' . $this->db->escape($index)
);
return $result->getNumRows() > 0;
}
}