diff --git a/src/Platforms/DB2Platform.php b/src/Platforms/DB2Platform.php index 3166e744f7..f0289802d5 100644 --- a/src/Platforms/DB2Platform.php +++ b/src/Platforms/DB2Platform.php @@ -468,40 +468,6 @@ private function getAlterColumnClausesSQL(ColumnDiff $columnDiff, bool &$needsRe return $clauses; } - /** - * {@inheritDoc} - */ - protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff): array - { - $sql = []; - - $tableNameSQL = $diff->getOldTable()->getObjectName()->toSQL($this); - - foreach ($diff->getDroppedIndexes() as $droppedIndex) { - foreach ($diff->getAddedIndexes() as $addedIndex) { - if ($droppedIndex->getColumns() !== $addedIndex->getColumns()) { - continue; - } - - if ($droppedIndex->isUnique()) { - $sql[] = 'ALTER TABLE ' . $tableNameSQL . ' DROP UNIQUE ' - . $droppedIndex->getObjectName()->toSQL($this); - } else { - $sql[] = $this->getDropIndexSQL($droppedIndex->getObjectName()->toSQL($this), $tableNameSQL); - } - - $sql[] = $this->getCreateIndexSQL($addedIndex, $tableNameSQL); - - $diff->unsetAddedIndex($addedIndex); - $diff->unsetDroppedIndex($droppedIndex); - - break; - } - } - - return array_merge($sql, parent::getPreAlterTableIndexForeignKeySQL($diff)); - } - /** * {@inheritDoc} */ diff --git a/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php index b23e3b9a40..2a902e146b 100644 --- a/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ b/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\DBAL\Schema\AbstractAsset; use Doctrine\DBAL\Schema\AbstractSchemaManager; +use Doctrine\DBAL\Schema\ComparatorConfig; use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Name\OptionallyQualifiedName; use Doctrine\DBAL\Schema\Name\UnqualifiedName; @@ -1431,7 +1432,9 @@ public function testChangeIndexWithForeignKeys(): void $child->dropIndex('idx_1'); $child->addIndex(['parent_id'], 'idx_2'); - $diff = $schemaManager->createComparator()->compareTables( + $diff = $schemaManager->createComparator( + (new ComparatorConfig())->withDetectRenamedIndexes(false), + )->compareTables( $schemaManager->introspectTable('child'), $child, );