Skip to content

Commit

Permalink
Make dropForeignIdFor method complementary to foreignIdFor (#54102)
Browse files Browse the repository at this point in the history
* Update tests to properly assert that only the column is dropped

* Drop the column instead of the foreign key
  • Loading branch information
willrowe authored Jan 7, 2025
1 parent 6c3a5a0 commit 941c439
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ public function dropForeignIdFor($model, $column = null)
$model = new $model;
}

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

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Database/DatabaseSchemaBlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public function testDropRelationshipColumnWithIncrementalModel()
};

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

Expand All @@ -457,7 +457,7 @@ public function testDropRelationshipColumnWithUuidModel()
};

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

Expand Down

0 comments on commit 941c439

Please sign in to comment.