Check if database exists and grand permission
Signed-off-by: Vitor Mattos <vitor@php.rio>
This commit is contained in:
parent
824cc0af1e
commit
4d187ce1d7
1 changed files with 4 additions and 2 deletions
|
@ -154,8 +154,10 @@ class PostgreSQL extends AbstractDatabase {
|
|||
// create the user
|
||||
$query = $connection->prepare("CREATE USER " . addslashes($this->dbUser) . " CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
|
||||
$query->execute();
|
||||
$query = $connection->prepare('GRANT CONNECT ON DATABASE ' . $this->dbName . ' TO '.addslashes($this->dbUser));
|
||||
$query->execute();
|
||||
if ($this->databaseExists($connection)) {
|
||||
$query = $connection->prepare('GRANT CONNECT ON DATABASE ' . $this->dbName . ' TO '.addslashes($this->dbUser));
|
||||
$query->execute();
|
||||
}
|
||||
} catch (DatabaseException $e) {
|
||||
$this->logger->error('Error while trying to create database user');
|
||||
$this->logger->logException($e);
|
||||
|
|
Loading…
Reference in a new issue