Skip to content

Commit

Permalink
Merge pull request #292 from alexislefebvre/chore-merge-2.x-in-3.x
Browse files Browse the repository at this point in the history
[3.x] merge `2.x` in `3.x`
  • Loading branch information
alexislefebvre authored Mar 11, 2024
2 parents c28e599 + 1894de4 commit 25eaa0b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 54 deletions.
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions src/Services/DatabaseTools/AbstractDatabaseTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
45 changes: 0 additions & 45 deletions src/Services/DatabaseTools/AbstractDbalDatabaseTool.php

This file was deleted.

18 changes: 15 additions & 3 deletions src/Services/DatabaseTools/ORMDatabaseTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,7 +29,7 @@
/**
* @author Aleksey Tupichenkov <[email protected]>
*/
class ORMDatabaseTool extends AbstractDbalDatabaseTool
class ORMDatabaseTool extends AbstractDatabaseTool
{
/**
* @var EntityManager
Expand All @@ -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';
Expand Down Expand Up @@ -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) {
}
Expand Down

0 comments on commit 25eaa0b

Please sign in to comment.