diff --git a/composer.json b/composer.json index 1a3ac779..c7193ae9 100644 --- a/composer.json +++ b/composer.json @@ -26,8 +26,8 @@ }, "require-dev": { "doctrine/data-fixtures": "^1.7", - "doctrine/doctrine-bundle": "^2.11", - "doctrine/doctrine-fixtures-bundle": "^3.5.1 || ^4.0", + "doctrine/doctrine-bundle": "^2.8", + "doctrine/doctrine-fixtures-bundle": "^3.4.4 || ^4.0", "doctrine/mongodb-odm-bundle": "^4.4 || ^5.0", "doctrine/orm": "^2.7", "doctrine/mongodb-odm": "^2.5", @@ -39,8 +39,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/AbstractDatabaseTool.php b/src/Services/DatabaseTools/AbstractDatabaseTool.php index c929a1fb..bffaf7c3 100644 --- a/src/Services/DatabaseTools/AbstractDatabaseTool.php +++ b/src/Services/DatabaseTools/AbstractDatabaseTool.php @@ -219,6 +219,4 @@ protected function getCacheMetadataParameter() return $this->container->hasParameter(self::CACHE_METADATA_PARAMETER_NAME) && false !== $this->container->getParameter(self::CACHE_METADATA_PARAMETER_NAME); } - - abstract protected function getPlatformName(): string; } diff --git a/src/Services/DatabaseTools/AbstractDbalDatabaseTool.php b/src/Services/DatabaseTools/AbstractDbalDatabaseTool.php deleted file mode 100755 index 30ce62e0..00000000 --- a/src/Services/DatabaseTools/AbstractDbalDatabaseTool.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Liip\TestFixturesBundle\Services\DatabaseTools; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Platforms\AbstractMySQLPlatform; -use Doctrine\DBAL\Platforms\PostgreSQLPlatform; -use Doctrine\DBAL\Platforms\SqlitePlatform; - -abstract class AbstractDbalDatabaseTool extends AbstractDatabaseTool -{ - protected Connection $connection; - - public function setObjectManagerName(?string $omName = null): void - { - parent::setObjectManagerName($omName); - $this->connection = $this->registry->getConnection($omName); - } - - protected function getPlatformName(): string - { - $platform = $this->connection->getDatabasePlatform(); - - if ($platform instanceof AbstractMySQLPlatform) { - return 'mysql'; - } elseif ($platform instanceof SqlitePlatform) { - return 'sqlite'; - } elseif ($platform instanceof PostgreSQLPlatform) { - return 'pgsql'; - } - - return parent::getPlatformName(); - } -} diff --git a/src/Services/DatabaseTools/ORMDatabaseTool.php b/src/Services/DatabaseTools/ORMDatabaseTool.php index f587fabe..143115f8 100644 --- a/src/Services/DatabaseTools/ORMDatabaseTool.php +++ b/src/Services/DatabaseTools/ORMDatabaseTool.php @@ -17,6 +17,7 @@ use Doctrine\Common\DataFixtures\Executor\ORMExecutor; use Doctrine\Common\DataFixtures\ProxyReferenceRepository; use Doctrine\Common\DataFixtures\Purger\ORMPurger; +use Doctrine\DBAL\Connection; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\ORM\Configuration; @@ -28,7 +29,7 @@ /** * @author Aleksey Tupichenkov */ -class ORMDatabaseTool extends AbstractDbalDatabaseTool +class ORMDatabaseTool extends AbstractDatabaseTool { /** * @var EntityManager @@ -37,6 +38,14 @@ class ORMDatabaseTool extends AbstractDbalDatabaseTool private bool $shouldEnableForeignKeyChecks = false; + protected Connection $connection; + + public function setObjectManagerName(?string $omName = null): void + { + parent::setObjectManagerName($omName); + $this->connection = $this->registry->getConnection($omName); + } + public function getType(): string { return 'ORM'; @@ -126,9 +135,12 @@ protected function createDatabaseIfNotExists(): void $tmpConnection = DriverManager::getConnection($params); + $schemaManager = $tmpConnection->createSchemaManager(); + + // 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) { }