fix school year for all tables
Tests / PHPUnit (push) Failing after 1m20s

This commit is contained in:
root
2026-07-18 14:45:38 -04:00
parent 4db8334a3c
commit 716cc8b8d3
125 changed files with 2315 additions and 81 deletions
@@ -8,16 +8,28 @@ class RevertPrintRequestsForeignKey extends Migration
{
public function up()
{
if (! $this->db->tableExists('print_requests')) {
return;
}
// Drop the old foreign key if it exists
$db = \Config\Database::connect();
$keys = $db->getForeignKeyData('print_requests');
foreach ($keys as $key) {
if ($key->constraint_name === 'print_requests_class_id_foreign') {
$this->forge->dropForeignKey('print_requests', 'print_requests_class_id_foreign');
try {
$this->forge->dropForeignKey('print_requests', 'print_requests_class_id_foreign');
} catch (\Throwable $e) {
// Already absent.
}
break;
}
}
if (! $this->db->tableExists('classes')) {
return;
}
// Add the new foreign key
$this->forge->addForeignKey('class_id', 'classes', 'id', 'CASCADE', 'CASCADE');
@@ -27,8 +39,20 @@ class RevertPrintRequestsForeignKey extends Migration
public function down()
{
if (! $this->db->tableExists('print_requests')) {
return;
}
// Drop the new foreign key
$this->forge->dropForeignKey('print_requests', 'print_requests_class_id_foreign');
try {
$this->forge->dropForeignKey('print_requests', 'print_requests_class_id_foreign');
} catch (\Throwable $e) {
// Already absent.
}
if (! $this->db->tableExists('class_sections')) {
return;
}
// Re-add the old foreign key
$this->forge->addForeignKey('class_id', 'class_sections', 'id', 'CASCADE', 'CASCADE');