8000 [Messenger] Fix calls to deprecated DBAL methods · symfony/symfony@2f834f2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f834f2

Browse files
committed
[Messenger] Fix calls to deprecated DBAL methods
1 parent 8a62b40 commit 2f834f2

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Doctrine\DBAL\Schema\AbstractSchemaManager;
2626
use Doctrine\DBAL\Schema\Comparator;
2727
use Doctrine\DBAL\Schema\Schema;
28+
use Doctrine\DBAL\Schema\SchemaDiff;
2829
use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer;
2930
use Doctrine\DBAL\Types\Type;
3031
use Doctrine\DBAL\Types\Types;
@@ -453,8 +454,9 @@ private function updateSchema(): void
453454
return;
454455
}
455456

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());
458460

459461
foreach ($schemaDiff->toSaveSql($this->driverConnection->getDatabasePlatform()) as $sql) {
460462
if (method_exists($this->driverConnection, 'executeStatement')) {
@@ -471,4 +473,18 @@ private function createSchemaManager(): AbstractSchemaManager
471473
? $this->driverConnection->createSchemaManager()
472474
: $this->driverConnection->getSchemaManager();
473475
}
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+
}
474490
}

0 commit comments

Comments
 (0)
0