|
16 | 16 | use Doctrine\DBAL\Exception\TableNotFoundException;
|
17 | 17 | use Doctrine\DBAL\Query\QueryBuilder;
|
18 | 18 | use Doctrine\DBAL\Schema\Schema;
|
| 19 | +use Doctrine\DBAL\Schema\SchemaConfig; |
19 | 20 | use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer;
|
20 | 21 | use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer;
|
21 | 22 | use Doctrine\DBAL\Types\Type;
|
@@ -52,12 +53,14 @@ class Connection
|
52 | 53 | private $configuration = [];
|
53 | 54 | private $driverConnection;
|
54 | 55 | private $schemaSynchronizer;
|
| 56 | + private $schemaConfig; |
55 | 57 |
|
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) |
57 | 59 | {
|
58 | 60 | $this->configuration = array_replace_recursive(self::DEFAULT_OPTIONS, $configuration);
|
59 | 61 | $this->driverConnection = $driverConnection;
|
60 | 62 | $this->schemaSynchronizer = $schemaSynchronizer ?? new SingleDatabaseSynchronizer($this->driverConnection);
|
| 63 | + $this->schemaConfig = $schemaConfig ?? ($this->driverConnection->getSchemaManager() ? $this->driverConnection->getSchemaManager()->createSchemaConfig() : null); |
61 | 64 | }
|
62 | 65 |
|
63 | 66 | public function getConfiguration(): array
|
@@ -304,7 +307,7 @@ private function executeQuery(string $sql, array $parameters = [])
|
304 | 307 |
|
305 | 308 | private function getSchema(): Schema
|
306 | 309 | {
|
307 |
| - $schema = new Schema(); |
| 310 | + $schema = new Schema([], [], $this->schemaConfig); |
308 | 311 | $table = $schema->createTable($this->configuration['table_name']);
|
309 | 312 | $table->addColumn('id', Type::BIGINT)
|
310 | 313 | ->setAutoincrement(true)
|
|
0 commit comments