Created NoDbNameConnectionFactoryTest

This commit is contained in:
Alejandro Celaya
2019-08-06 17:30:28 +02:00
parent a575f2eced
commit e79c41d753
2 changed files with 59 additions and 1 deletions

View File

@@ -68,9 +68,11 @@ class CreateDatabaseCommand extends AbstractDatabaseCommand
private function checkDbExists(): void
{
$shlinkDatabase = $this->conn->getDatabase();
// In order to create the new database, we have to use a connection where the dbname was not set.
// Otherwise, it will fail to connect and will not be able to create the new database
$schemaManager = $this->noDbNameConn->getSchemaManager();
$databases = $schemaManager->listDatabases();
$shlinkDatabase = $this->conn->getDatabase();
if (! contains($databases, $shlinkDatabase)) {
$schemaManager->createDatabase($shlinkDatabase);