db->tableExists('print_requests')) { return; } // Drop the old foreign key if it exists try { $this->forge->dropForeignKey('print_requests', 'print_requests_class_id_foreign'); } catch (\Throwable $e) { // Already absent. } } public function down() { if (! $this->db->tableExists('print_requests') || ! $this->db->tableExists('class_sections')) { return; } // Re-add the old foreign key $this->forge->addForeignKey('class_id', 'class_sections', 'id', 'CASCADE', 'CASCADE'); // Process the modifications $this->forge->processIndexes('print_requests'); } }