Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b1c2e56

Browse files
committed
[Messenger] Retrieve table default options from the SchemaManager
1 parent 950306a commit b1c2e56

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Doctrine\DBAL\Exception\TableNotFoundException;
1717
use Doctrine\DBAL\Query\QueryBuilder;
1818
use Doctrine\DBAL\Schema\Schema;
19+
use Doctrine\DBAL\Schema\SchemaConfig;
1920
use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer;
2021
use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer;
2122
use Doctrine\DBAL\Types\Type;
@@ -52,12 +53,14 @@ class Connection
5253
private $configuration = [];
5354
private $driverConnection;
5455
private $schemaSynchronizer;
56+
private $schemaConfig;
5557

56-
public function __construct(array $configuration, DBALConnection $driverConnection, SchemaSynchronizer $schemaSynchronizer = null)
58+
public function __construct(array $configuration, DBALConnection $driverConnection, SchemaSynchronizer $schemaSynchronizer = null, SchemaConfig $schemaConfig = null)
5759
{
5860
$this->configuration = array_replace_recursive(self::DEFAULT_OPTIONS, $configuration);
5961
$this->driverConnection = $driverConnection;
6062
$this->schemaSynchronizer = $schemaSynchronizer ?? new SingleDatabaseSynchronizer($this->driverConnection);
63+
$this->schemaConfig = $schemaConfig ?? ($this->driverConnection->getSchemaManager() ? $this->driverConnection->getSchemaManager()->createSchemaConfig() : null);
6164
}
6265

6366
public function getConfiguration(): array
@@ -304,7 +307,7 @@ private function executeQuery(string $sql, array $parameters = [])
304307

305308
private function getSchema(): Schema
306309
{
307-
$schema = new Schema();
310+
$schema = new Schema([], [], $this->schemaConfig);
308311
$table = $schema->createTable($this->configuration['table_name']);
309312
$table->addColumn('id', Type::BIGINT)
310313
->setAutoincrement(true)

0 commit comments

Comments
 (0)