Merge pull request #2535 from nextcloud/allow-to-reuse-admin-as-install-name-like-on-mysql
Allow to reuse the same name when installing a new instance on postgres
This commit is contained in:
commit
9e95a89ab7
|
@ -150,14 +150,16 @@ class PostgreSQL extends AbstractDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createDBUser(IDBConnection $connection) {
|
private function createDBUser(IDBConnection $connection) {
|
||||||
|
$dbUser = $this->dbUser;
|
||||||
try {
|
try {
|
||||||
if ($this->userExists($connection)) {
|
$i = 1;
|
||||||
// change the password
|
while ($this->userExists($connection)) {
|
||||||
$query = $connection->prepare("ALTER ROLE " . addslashes($this->dbUser) . " WITH CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
|
$i++;
|
||||||
} else {
|
$this->dbUser = $dbUser . $i;
|
||||||
// create the user
|
};
|
||||||
$query = $connection->prepare("CREATE USER " . addslashes($this->dbUser) . " CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
|
|
||||||
}
|
// create the user
|
||||||
|
$query = $connection->prepare("CREATE USER " . addslashes($this->dbUser) . " CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
|
||||||
$query->execute();
|
$query->execute();
|
||||||
} catch (DatabaseException $e) {
|
} catch (DatabaseException $e) {
|
||||||
$this->logger->error('Error while trying to create database user');
|
$this->logger->error('Error while trying to create database user');
|
||||||
|
|
Loading…
Reference in New Issue