This commit is contained in:
@@ -8,8 +8,16 @@ class FixPrintRequestsForeignKey extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
if (! $this->db->tableExists('print_requests')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Drop the old foreign key if it exists
|
||||
$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;
|
||||
@@ -24,8 +32,20 @@ class FixPrintRequestsForeignKey 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('classes')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Re-add the old foreign key
|
||||
$this->forge->addForeignKey('class_id', 'classes', 'id', 'CASCADE', 'CASCADE');
|
||||
|
||||
Reference in New Issue
Block a user