Skip to content

Commit 0ef61fc

Browse files
authored
fix warning in info when using connection config (#2312)
1 parent 2e9d7d2 commit 0ef61fc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Phinx/Console/Command/AbstractCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Phinx\Console\Command;
1010

1111
use InvalidArgumentException;
12+
use PDO;
1213
use Phinx\Config\Config;
1314
use Phinx\Config\ConfigInterface;
1415
use Phinx\Db\Adapter\AdapterInterface;
@@ -467,7 +468,12 @@ protected function writeInformationOutput(?string &$environment, OutputInterface
467468

468469
if (isset($envOptions['name'])) {
469470
$name = $envOptions['name'];
470-
if ($envOptions['adapter'] === 'sqlite') {
471+
// We do error handling for missing adapter or connection is invalid later on running a command
472+
$adapter = $envOptions['adapter'] ?? null;
473+
if (isset($envOptions['connection']) && $envOptions['connection'] instanceof PDO) {
474+
$adapter = $envOptions['connection']->getAttribute(PDO::ATTR_DRIVER_NAME);
475+
}
476+
if ($adapter === 'sqlite') {
471477
$name .= SQLiteAdapter::getSuffix($envOptions);
472478
}
473479
$output->writeln('<info>using database</info> ' . $name, $this->verbosityLevel);

0 commit comments

Comments
 (0)