diff --git a/composer.json b/composer.json index 58a6bb5e..0dde01c4 100644 --- a/composer.json +++ b/composer.json @@ -25,12 +25,14 @@ "symfony/yaml": "^5.4 || ^6.3 || ^7.0" }, "require-dev": { - "doctrine/annotations": "^1.8.0 || ^2.0", - "doctrine/data-fixtures": "^1.7", - "doctrine/doctrine-bundle": "^2.11", - "doctrine/doctrine-fixtures-bundle": "^3.5.1 || ^4.0", - "doctrine/mongodb-odm-bundle": "^4.2 || ^5.0", - "doctrine/orm": "^2.7", + "doctrine/annotations": "^1.13.1 || ^2.0", + "doctrine/data-fixtures": "^1.4.4", + "doctrine/dbal": "^2.13.1 || ^3.1", + "doctrine/doctrine-bundle": "^2.2", + "doctrine/doctrine-fixtures-bundle": "^3.4.4 || ^4.0", + "doctrine/mongodb-odm": "^2.2", + "doctrine/mongodb-odm-bundle": "^4.2.1 || ^5.0", + "doctrine/orm": "^2.14", "doctrine/phpcr-bundle": "^2.4.3 || ^3.0", "doctrine/phpcr-odm": "^1.7.2 || ^2.0", "jackalope/jackalope-doctrine-dbal": "^1.10.1 || ^2.0", @@ -43,8 +45,10 @@ "theofidry/alice-data-fixtures": "^1.5.2" }, "conflict": { - "doctrine/annotations": "<1.2.7 || >=3.0", - "doctrine/dbal": "<2.11" + "doctrine/annotations": "<1.13.1 || >=3.0", + "doctrine/dbal": "<2.13.1 || ~3.0.0 || >=4.0", + "doctrine/mongodb-odm": "<2.2 || >=3.0", + "doctrine/orm": "<2.14 || >=3.0" }, "suggest": { "doctrine/dbal": "Required when using the fixture loading functionality with an ORM and SQLite", diff --git a/src/Services/DatabaseTools/AbstractDbalDatabaseTool.php b/src/Services/DatabaseTools/AbstractDbalDatabaseTool.php index 7392f199..a767ac12 100755 --- a/src/Services/DatabaseTools/AbstractDbalDatabaseTool.php +++ b/src/Services/DatabaseTools/AbstractDbalDatabaseTool.php @@ -15,6 +15,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Platforms\AbstractMySQLPlatform; +use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\DBAL\Platforms\SqlitePlatform; @@ -32,7 +33,8 @@ protected function getPlatformName(): string { $platform = $this->connection->getDatabasePlatform(); - if ($platform instanceof AbstractMySQLPlatform) { + // AbstractMySQLPlatform was introduced in DBAL 3.3, keep the MySQLPlatform checks for compatibility with older versions + if ($platform instanceof AbstractMySQLPlatform || $platform instanceof MySqlPlatform) { return 'mysql'; } elseif ($platform instanceof SqlitePlatform) { return 'sqlite'; @@ -40,6 +42,6 @@ protected function getPlatformName(): string return 'pgsql'; } - return parent::getPlatformName(); + return (new \ReflectionClass($platform))->getShortName(); } } diff --git a/src/Services/DatabaseTools/ORMDatabaseTool.php b/src/Services/DatabaseTools/ORMDatabaseTool.php index 7026133c..b8f59128 100644 --- a/src/Services/DatabaseTools/ORMDatabaseTool.php +++ b/src/Services/DatabaseTools/ORMDatabaseTool.php @@ -178,9 +178,16 @@ protected function createDatabaseIfNotExists(): void $tmpConnection = DriverManager::getConnection($params); + if (method_exists($tmpConnection, 'createSchemaManager')) { + $schemaManager = $tmpConnection->createSchemaManager(); + } else { + $schemaManager = $tmpConnection->getSchemaManager(); + } + + // DBAL 4.x does not support creating databases for SQLite anymore; for now we silently ignore this error try { - if (!\in_array($dbName, $tmpConnection->createSchemaManager()->listDatabases(), true)) { - $tmpConnection->createSchemaManager()->createDatabase($dbName); + if (!\in_array($dbName, $schemaManager->listDatabases(), true)) { + $schemaManager->createDatabase($dbName); } } catch (\Doctrine\DBAL\Platforms\Exception\NotSupported $e) { }