This commit is contained in:
@@ -8,6 +8,10 @@ class FixPrintRequestsForeignKeyAgain extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
if (! $this->db->tableExists('print_requests') || ! $this->db->tableExists('classSection')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
$keys = $db->getForeignKeyData('print_requests');
|
||||
foreach ($keys as $key) {
|
||||
@@ -22,6 +26,14 @@ class FixPrintRequestsForeignKeyAgain extends Migration
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropForeignKey('print_requests', 'print_requests_class_id_foreign');
|
||||
if (! $this->db->tableExists('print_requests')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->forge->dropForeignKey('print_requests', 'print_requests_class_id_foreign');
|
||||
} catch (\Throwable $e) {
|
||||
// Already absent.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user