Skip to content

Commit 6316ebc

Browse files
committed
Fix doctrine:database:create failing without server_version for some connections
getDatabasePlatform() triggers a connection to auto-detect the server version when server_version is not configured. Since the target database does not exist yet at this point, the connection fails. Switch to getDriver() which identifies the driver type without opening any connection.
1 parent c747e6a commit 6316ebc

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/Command/CreateDatabaseDoctrineCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Doctrine\Bundle\DoctrineBundle\Command;
66

7+
use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
78
use Doctrine\DBAL\DriverManager;
8-
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
99
use InvalidArgumentException;
1010
use Symfony\Component\Console\Input\InputInterface;
1111
use Symfony\Component\Console\Input\InputOption;
@@ -68,7 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6868
/** @phpstan-ignore unset.offset */
6969
unset($params['dbname'], $params['path'], $params['url']);
7070

71-
if ($connection->getDatabasePlatform() instanceof PostgreSQLPlatform) {
71+
if ($connection->getDriver() instanceof AbstractPostgreSQLDriver) {
7272
/** @phpstan-ignore nullCoalesce.offset (needed for DBAL < 4) */
7373
$params['dbname'] = $params['default_dbname'] ?? 'postgres';
7474
}

0 commit comments

Comments
 (0)