Skip to content

Commit

Permalink
Fix db drop and schema create commands with default_dbname option
Browse files Browse the repository at this point in the history
Fixes #1783
  • Loading branch information
ostrolucky committed Mar 23, 2024
1 parent 7f209ad commit c31c174
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Command/CreateDatabaseDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
unset($params['dbname'], $params['path'], $params['url']);

if ($connection->getDatabasePlatform() instanceof PostgreSQLPlatform) {
$params['dbname'] = 'postgres';
/** @psalm-suppress InvalidArrayOffset It's still available in DBAL 3.x that we need to support */
$params['dbname'] = $params['default_dbname'] ?? 'postgres';

Check warning on line 70 in src/Command/CreateDatabaseDoctrineCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Command/CreateDatabaseDoctrineCommand.php#L70

Added line #L70 was not covered by tests
}

$tmpConnection = DriverManager::getConnection($params, $connection->getConfiguration());
Expand Down
3 changes: 2 additions & 1 deletion src/Command/DropDatabaseDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
unset($params['dbname'], $params['url']);

if ($connection->getDatabasePlatform() instanceof PostgreSQLPlatform) {
$params['dbname'] = 'postgres';
/** @psalm-suppress InvalidArrayOffset It's still available in DBAL 3.x that we need to support */
$params['dbname'] = $params['default_dbname'] ?? 'postgres';

Check warning on line 81 in src/Command/DropDatabaseDoctrineCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Command/DropDatabaseDoctrineCommand.php#L81

Added line #L81 was not covered by tests
}

if (! $input->getOption('force')) {
Expand Down

0 comments on commit c31c174

Please sign in to comment.