25
25
use Doctrine \DBAL \Schema \AbstractSchemaManager ;
26
26
use Doctrine \DBAL \Schema \Comparator ;
27
27
use Doctrine \DBAL \Schema \Schema ;
28
+ use Doctrine \DBAL \Schema \SchemaDiff ;
28
29
use Doctrine \DBAL \Schema \Synchronizer \SchemaSynchronizer ;
29
30
use Doctrine \DBAL \Types \Type ;
30
31
use Doctrine \DBAL \Types \Types ;
@@ -453,8 +454,9 @@ private function updateSchema(): void
453
454
return ;
454
455
}
455
456
456
- $ comparator = new Comparator ();
457
- $ schemaDiff = $ comparator ->compare ($ this ->createSchemaManager ()->createSchema (), $ this ->getSchema ());
457
+ $ schemaManager = $ this ->createSchemaManager ();
458
+ $ comparator = $ this ->createComparator ($ schemaManager );
459
+ $ schemaDiff = $ this ->compareSchemas ($ comparator , $ schemaManager ->createSchema (), $ this ->getSchema ());
458
460
459
461
foreach ($ schemaDiff ->toSaveSql ($ this ->driverConnection ->getDatabasePlatform ()) as $ sql ) {
460
462
if (method_exists ($ this ->driverConnection , 'executeStatement ' )) {
@@ -471,4 +473,18 @@ private function createSchemaManager(): AbstractSchemaManager
471
473
? $ this ->driverConnection ->createSchemaManager ()
472
474
: $ this ->driverConnection ->getSchemaManager ();
473
475
}
476
+
477
+ private function createComparator (AbstractSchemaManager $ schemaManager ): Comparator
478
+ {
479
+ return method_exists ($ schemaManager , 'createComparator ' )
480
+ ? $ schemaManager ->createComparator ()
481
+ : new Comparator ();
482
+ }
483
+
484
+ private function compareSchemas (Comparator $ comparator , Schema $ from , Schema $ to ): SchemaDiff
485
+ {
486
+ return method_exists ($ comparator , 'compareSchemas ' )
487
+ ? $ comparator ->compareSchemas ($ from , $ to )
488
+ : $ comparator ->compare ($ from , $ to );
489
+ }
474
490
}
0 commit comments