@@ -228,31 +228,35 @@ public function compareTables(Table $oldTable, Table $newTable): TableDiff
228228 $ folding = $ this ->platform ->getUnquotedIdentifierFolding ();
229229
230230 // See if all the indexes from the old table exist in the new one
231- foreach ($ newIndexes as $ newIndexName => $ newIndex ) {
232- if ($ oldTable ->hasIndex ($ newIndexName )) {
231+ foreach ($ newIndexes as $ newIndex ) {
232+ $ newIndexName = $ newIndex ->getObjectName ();
233+
234+ if ($ oldTable ->hasIndex ($ newIndexName ->toString ())) {
233235 continue ;
234236 }
235237
236- $ addedIndexes [$ newIndexName ] = $ newIndex ;
238+ $ addedIndexes [] = $ newIndex ;
237239 }
238240
239241 // See if there are any removed indexes in the new table
240- foreach ($ oldIndexes as $ oldIndexName => $ oldIndex ) {
241- if (! $ newTable ->hasIndex ($ oldIndexName )) {
242- $ droppedIndexes [$ oldIndexName ] = $ oldIndex ;
242+ foreach ($ oldIndexes as $ oldIndex ) {
243+ $ oldIndexName = $ oldIndex ->getObjectName ();
244+
245+ if (! $ newTable ->hasIndex ($ oldIndexName ->toString ())) {
246+ $ droppedIndexes [] = $ oldIndex ;
243247
244248 continue ;
245249 }
246250
247251 // See if index has changed in the new table.
248- $ newIndex = $ newTable ->getIndex ($ oldIndexName );
252+ $ newIndex = $ newTable ->getIndex ($ oldIndexName-> toString () );
249253
250254 if ($ oldIndex ->equals ($ newIndex , $ folding )) {
251255 continue ;
252256 }
253257
254- $ droppedIndexes [$ oldIndexName ] = $ oldIndex ;
255- $ addedIndexes [$ oldIndexName ] = $ newIndex ;
258+ $ droppedIndexes [] = $ oldIndex ;
259+ $ addedIndexes [] = $ newIndex ;
256260 }
257261
258262 if ($ this ->config ->getDetectRenamedIndexes ()) {
@@ -376,8 +380,8 @@ private function primaryKeyConstraintsEqual(
376380 * Try to find indexes that only changed their name, rename operations maybe cheaper than add/drop
377381 * however ambiguities between different possibilities should not lead to renaming at all.
378382 *
379- * @param array<string, Index> $addedIndexes
380- * @param array<string, Index> $removedIndexes
383+ * @param array<Index> $addedIndexes
384+ * @param array<Index> $removedIndexes
381385 *
382386 * @return array<string,Index>
383387 */
@@ -389,15 +393,15 @@ private function detectRenamedIndexes(
389393 $ candidatesByName = [];
390394
391395 // Gather possible rename candidates by comparing each added and removed index based on semantics.
392- foreach ($ addedIndexes as $ addedIndexName => $ addedIndex ) {
393- foreach ($ removedIndexes as $ removedIndex ) {
396+ foreach ($ addedIndexes as $ addedIndexKey => $ addedIndex ) {
397+ foreach ($ removedIndexes as $ removedIndexKey => $ removedIndex ) {
394398 if (! $ addedIndex ->equals ($ removedIndex , $ folding )) {
395399 continue ;
396400 }
397401
398402 $ candidatesByName [$ addedIndex ->getObjectName ()
399403 ->getIdentifier ()
400- ->getValue ()][] = [$ removedIndex , $ addedIndex , $ addedIndexName ];
404+ ->getValue ()][] = [$ removedIndexKey , $ addedIndexKey ];
401405 }
402406 }
403407
@@ -412,28 +416,25 @@ private function detectRenamedIndexes(
412416 continue ;
413417 }
414418
415- [$ removedIndex , $ addedIndex ] = $ candidates [0 ];
419+ [$ removedIndexKey , $ addedIndexKey ] = $ candidates [0 ];
416420
421+ $ removedIndex = $ removedIndexes [$ removedIndexKey ];
417422 $ removedIndexName = strtolower (
418423 $ removedIndex ->getObjectName ()
419424 ->getIdentifier ()
420425 ->getValue (),
421426 );
422427
423- $ addedIndexName = strtolower (
424- $ addedIndex ->getObjectName ()
425- ->getIdentifier ()
426- ->getValue (),
427- );
428-
429428 if (isset ($ renamedIndexes [$ removedIndexName ])) {
430429 continue ;
431430 }
432431
432+ $ addedIndex = $ addedIndexes [$ addedIndexKey ];
433+
433434 $ renamedIndexes [$ removedIndexName ] = $ addedIndex ;
434435 unset(
435- $ addedIndexes [$ addedIndexName ],
436- $ removedIndexes [$ removedIndexName ],
436+ $ addedIndexes [$ addedIndexKey ],
437+ $ removedIndexes [$ removedIndexKey ],
437438 );
438439 }
439440
0 commit comments