summaryrefslogtreecommitdiffstats
path: root/lib/private/Setup
diff options
context:
space:
mode:
authorVitor Mattos <vitor@php.rio>2019-04-21 16:54:40 -0300
committerVitor Mattos <vitor@php.rio>2019-04-21 16:54:40 -0300
commit4d187ce1d7ebaa8bc26055e6e85796dc39386e8e (patch)
treecf60feb1c96be6a94bf93857659e86fafa80ef92 /lib/private/Setup
parent824cc0af1ef91394c98d405d672f63e425d375d5 (diff)
downloadnextcloud-server-4d187ce1d7ebaa8bc26055e6e85796dc39386e8e.tar.gz
nextcloud-server-4d187ce1d7ebaa8bc26055e6e85796dc39386e8e.zip
Check if database exists and grand permission
Signed-off-by: Vitor Mattos <vitor@php.rio>
Diffstat (limited to 'lib/private/Setup')
-rw-r--r--lib/private/Setup/PostgreSQL.php6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/private/Setup/PostgreSQL.php b/lib/private/Setup/PostgreSQL.php
index 23c5ec73929..9bd4e57f60f 100644
--- a/lib/private/Setup/PostgreSQL.php
+++ b/lib/private/Setup/PostgreSQL.php
@@ -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);