Force server version to avoid connexion error

When installing a new project with MySQL, if the database doesn't exist before installation will fail because DBAL will try to get the server version by querying it.
And since this query is done using the default database connexion and since the database doesn't exist, DBAL can't connect to the server.
This commit is contained in:
Jeremy Benoist 2016-04-10 15:34:32 +02:00
parent 615fc1d237
commit 69c21157ba
2 changed files with 8 additions and 1 deletions

View file

@ -82,6 +82,7 @@ doctrine:
password: "%database_password%"
charset: UTF8
path: "%database_path%"
server_version: 5.6
orm:
auto_generate_proxy_classes: "%kernel.debug%"

View file

@ -455,7 +455,13 @@ class InstallCommand extends ContainerAwareCommand
return false;
}
try {
return in_array($databaseName, $schemaManager->listDatabases());
} catch (\Doctrine\DBAL\Exception\ConnectionException $e) {
// it means we weren't able to get database list, assume the database doesn't exist
return false;
}
}
/**