24
24
use Doctrine \DBAL \Schema \AbstractSchemaManager ;
25
25
use Doctrine \DBAL \Schema \Comparator ;
26
26
use Doctrine \DBAL \Schema \Schema ;
27
+ use Doctrine \DBAL \Schema \SchemaDiff ;
27
28
use Doctrine \DBAL \Schema \Synchronizer \SchemaSynchronizer ;
28
29
use Doctrine \DBAL \Schema \Table ;
29
30
use Doctrine \DBAL \Types \Types ;
@@ -467,8 +468,9 @@ private function updateSchema(): void
467
468
return ;
468
469
}
469
470
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 ());
472
474
473
475
foreach ($ schemaDiff ->toSaveSql ($ this ->driverConnection ->getDatabasePlatform ()) as $ sql ) {
474
476
if (method_exists ($ this ->driverConnection , 'executeStatement ' )) {
@@ -485,6 +487,20 @@ private function createSchemaManager(): AbstractSchemaManager
485
487
? $ this ->driverConnection ->createSchemaManager ()
486
488
: $ this ->driverConnection ->getSchemaManager ();
487
489
}
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 );
503
+ }
488
504
}
489
505
490
506
if (!class_exists (\Symfony \Component \Messenger \Transport \Doctrine \Connection::class, false )) {
0 commit comments