Skip to content

Commit 941c439

Browse files
authored
Make dropForeignIdFor method complementary to foreignIdFor (laravel#54102)
* Update tests to properly assert that only the column is dropped * Drop the column instead of the foreign key
1 parent 6c3a5a0 commit 941c439

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Illuminate/Database/Schema/Blueprint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ public function dropForeignIdFor($model, $column = null)
531531
$model = new $model;
532532
}
533533

534-
return $this->dropForeign([$column ?: $model->getForeignKey()]);
534+
return $this->dropColumn($column ?: $model->getForeignKey());
535535
}
536536

537537
/**

tests/Database/DatabaseSchemaBlueprintTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ public function testDropRelationshipColumnWithIncrementalModel()
444444
};
445445

446446
$this->assertEquals([
447-
'alter table `posts` drop foreign key `posts_user_id_foreign`',
447+
'alter table `posts` drop `user_id`',
448448
], $getSql(new MySqlGrammar));
449449
}
450450

@@ -457,7 +457,7 @@ public function testDropRelationshipColumnWithUuidModel()
457457
};
458458

459459
$this->assertEquals([
460-
'alter table `posts` drop foreign key `posts_model_using_uuid_id_foreign`',
460+
'alter table `posts` drop `model_using_uuid_id`',
461461
], $getSql(new MySqlGrammar));
462462
}
463463

0 commit comments

Comments
 (0)