Files
alrahma_sunday_school/app/Database/Migrations/2026-01-05-215851_FixPrintRequestsForeignKey.php
T
root a56aca4342
Tests / PHPUnit (push) Failing after 1m16s
fix tests issues
2026-07-13 00:24:00 -04:00

37 lines
1022 B
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class FixPrintRequestsForeignKey extends Migration
{
public function up()
{
// Drop the old foreign key if it exists
$this->forge->dropForeignKey('print_requests', 'print_requests_class_id_foreign');
if (! $this->db->tableExists('class_sections')) {
return;
}
// Add the new foreign key
$this->forge->addForeignKey('class_id', 'class_sections', 'id', 'CASCADE', 'CASCADE');
// Process the modifications
$this->forge->processIndexes('print_requests');
}
public function down()
{
// Drop the new foreign key
$this->forge->dropForeignKey('print_requests', 'print_requests_class_id_foreign');
// Re-add the old foreign key
$this->forge->addForeignKey('class_id', 'classes', 'id', 'CASCADE', 'CASCADE');
// Process the modifications
$this->forge->processIndexes('print_requests');
}
}