Skip to content

Commit 116183b

Browse files
author
Christoph Krapp
committed
Fix fk name change detection in schema comparator
As index renaming support was introduced a while back do the same for foreign key name changes. Signed-off-by: Christoph Krapp <[email protected]>
1 parent a5d2baf commit 116183b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Schema/Comparator.php

+4
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,10 @@ private function detectRenamedIndexes(array &$addedIndexes, array &$removedIndex
555555
*/
556556
public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint $key2)
557557
{
558+
if (strtolower($key1->getName()) !== strtolower($key2->getName())) {
559+
return true;
560+
}
561+
558562
if (
559563
array_map('strtolower', $key1->getUnquotedLocalColumns())
560564
!== array_map('strtolower', $key2->getUnquotedLocalColumns())

tests/Schema/AbstractComparatorTestCase.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,10 @@ public function testCompareForeignKeyBasedOnPropertiesNotName(): void
683683
$tableB->addForeignKeyConstraint('bar', ['id'], ['id'], [], 'bar_constraint');
684684

685685
$tableDiff = $this->comparator->diffTable($tableA, $tableB);
686+
self::assertNotFalse($tableDiff);
687+
self::assertCount(1, $tableDiff->addedForeignKeys);
688+
self::assertCount(1, $tableDiff->removedForeignKeys);
686689

687-
self::assertFalse($tableDiff);
688690
}
689691

690692
public function testCompareForeignKeyRestrictNoActionAreTheSame(): void

0 commit comments

Comments
 (0)