2424use Doctrine \DBAL \Schema \AbstractSchemaManager ;
2525use Doctrine \DBAL \Schema \Comparator ;
2626use Doctrine \DBAL \Schema \Schema ;
27+ use Doctrine \DBAL \Schema \SchemaDiff ;
2728use Doctrine \DBAL \Schema \Synchronizer \SchemaSynchronizer ;
2829use Doctrine \DBAL \Schema \Table ;
2930use Doctrine \DBAL \Types \Types ;
@@ -467,8 +468,9 @@ private function updateSchema(): void
467468 return ;
468469 }
469470
470- $ comparator = new Comparator ();
471- $ schemaDiff = $ comparator ->compare ($ this ->createSchemaManager ()->createSchema (), $ this ->getSchema ());
471+ $ schemaManager = $ this ->createSchemaManager ();
472+ $ comparator = $ this ->createComparator ($ schemaManager );
473+ $ schemaDiff = $ this ->compareSchemas ($ comparator , $ schemaManager ->createSchema (), $ this ->getSchema ());
472474
473475 foreach ($ schemaDiff ->toSaveSql ($ this ->driverConnection ->getDatabasePlatform ()) as $ sql ) {
474476 if (method_exists ($ this ->driverConnection , 'executeStatement ' )) {
@@ -485,6 +487,20 @@ private function createSchemaManager(): AbstractSchemaManager
485487 ? $ this ->driverConnection ->createSchemaManager ()
486488 : $ this ->driverConnection ->getSchemaManager ();
487489 }
490+
491+ private function createComparator (AbstractSchemaManager $ schemaManager ): Comparator
492+ {
493+ return method_exists ($ schemaManager , 'createComparator ' )
494+ ? $ schemaManager ->createComparator ()
495+ : new Comparator ();
496+ }
497+
498+ private function compareSchemas (Comparator $ comparator , Schema $ from , Schema $ to ): SchemaDiff
499+ {
500+ return method_exists ($ comparator , 'compareSchemas ' )
501+ ? $ comparator ->compareSchemas ($ from , $ to )
502+ : $ comparator ->compare ($ from , $ to );
4C61
503+ }
488504}
489505
490506if (!class_exists (\Symfony \Component \Messenger \Transport \Doctrine \Connection::class, false )) {
0 commit comments