try { // check connection
$connection =
$this->connectionFactory->
getConnection($connectionInfo);
} catch (DriverException
$e) { // Unknown database https://dev.mysql.com/doc/refman/8.0/en/server-error-reference.html#error_er_bad_db_error
if ($e->
getCode() !== 1049
) { throw $e;
} $connection =
$this->connectionFactory->
getConnection($connectionInfo, true
);
$this->setupDatabaseAdapter->
createDatabase($connection,
$connectionInfo->
getDatabaseName());
$connection =
$this->connectionFactory->
getConnection($connectionInfo);
} $session->
set(DatabaseConnectionInformation::
class,
$connectionInfo);
$this->blueGreenDeploymentService->
setEnvironmentVariable($connection,
$session);
if ($this->setupDatabaseAdapter->
getTableCount($connection,
$connectionInfo->
getDatabaseName())) { $connectionInfo->
setDatabaseName(''
);