Skip to content

Commit

Permalink
[Messenger] Preserve existing Doctrine schema
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Jun 22, 2023
1 parent 173c519 commit ed4055b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
3 changes: 1 addition & 2 deletions Store/DoctrineDbalPostgreSqlStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
use Doctrine\DBAL\Tools\DsnParser;
use Doctrine\ORM\ORMSetup;
use Symfony\Component\Lock\BlockingSharedLockStoreInterface;
use Symfony\Component\Lock\BlockingStoreInterface;
use Symfony\Component\Lock\Exception\InvalidArgumentException;
Expand Down Expand Up @@ -71,7 +70,7 @@ public function __construct($connOrUrl)
$params = ['url' => $this->filterDsn($connOrUrl)];
}

$config = class_exists(ORMSetup::class) ? ORMSetup::createConfiguration() : new Configuration();
$config = new Configuration();
if (class_exists(DefaultSchemaManagerFactory::class)) {
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
}
Expand Down
3 changes: 1 addition & 2 deletions Store/DoctrineDbalStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Tools\DsnParser;
use Doctrine\ORM\ORMSetup;
use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\Exception\InvalidTtlException;
use Symfony\Component\Lock\Exception\LockConflictedException;
Expand Down Expand Up @@ -88,7 +87,7 @@ public function __construct($connOrUrl, array $options = [], float $gcProbabilit
$params = ['url' => $connOrUrl];
}

$config = class_exists(ORMSetup::class) ? ORMSetup::createConfiguration() : new Configuration();
$config = new Configuration();
if (class_exists(DefaultSchemaManagerFactory::class)) {
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
}
Expand Down
3 changes: 1 addition & 2 deletions Tests/Store/DoctrineDbalPostgreSqlStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Doctrine\DBAL\Exception as DBALException;
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
use Doctrine\DBAL\Tools\DsnParser;
use Doctrine\ORM\ORMSetup;
use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Key;
Expand Down Expand Up @@ -176,7 +175,7 @@ public function testWaitAndSaveReadAfterConflictReleasesLockFromInternalStore()
private static function getDbalConnection(string $dsn): Connection
{
$params = class_exists(DsnParser::class) ? (new DsnParser(['sqlite' => 'pdo_sqlite']))->parse($dsn) : ['url' => $dsn];
$config = class_exists(ORMSetup::class) ? ORMSetup::createConfiguration(true) : new Configuration();
$config = new Configuration();
if (class_exists(DefaultSchemaManagerFactory::class)) {
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
}
Expand Down
5 changes: 2 additions & 3 deletions Tests/Store/DoctrineDbalStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Doctrine\DBAL\Exception\TableNotFoundException;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
use Doctrine\ORM\ORMSetup;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\PersistingStoreInterface;
use Symfony\Component\Lock\Store\DoctrineDbalStore;
Expand All @@ -39,7 +38,7 @@ public static function setUpBeforeClass(): void
{
self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_lock');

$config = class_exists(ORMSetup::class) ? ORMSetup::createConfiguration(true) : new Configuration();
$config = new Configuration();
if (class_exists(DefaultSchemaManagerFactory::class)) {
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
}
Expand All @@ -66,7 +65,7 @@ protected function getClockDelay()
*/
public function getStore(): PersistingStoreInterface
{
$config = class_exists(ORMSetup::class) ? ORMSetup::createConfiguration(true) : new Configuration();
$config = new Configuration();
if (class_exists(DefaultSchemaManagerFactory::class)) {
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
}
Expand Down
5 changes: 2 additions & 3 deletions Tests/Store/PdoDbalStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\ORM\ORMSetup;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\PersistingStoreInterface;
Expand All @@ -40,7 +39,7 @@ public static function setUpBeforeClass(): void
{
self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_lock');

$config = class_exists(ORMSetup::class) ? ORMSetup::createConfiguration(true) : new Configuration();
$config = new Configuration();
if (class_exists(DefaultSchemaManagerFactory::class)) {
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
}
Expand Down Expand Up @@ -69,7 +68,7 @@ public function getStore(): PersistingStoreInterface
{
$this->expectDeprecation('Since symfony/lock 5.4: Usage of a DBAL Connection with "Symfony\Component\Lock\Store\PdoStore" is deprecated and will be removed in symfony 6.0. Use "Symfony\Component\Lock\Store\DoctrineDbalStore" instead.');

$config = class_exists(ORMSetup::class) ? ORMSetup::createConfiguration(true) : new Configuration();
$config = new Configuration();
if (class_exists(DefaultSchemaManagerFactory::class)) {
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
}
Expand Down

0 comments on commit ed4055b

Please sign in to comment.