Skip to content

Commit eb7b682

Browse files
vitormattosnickvergessen
authored andcommitted
Bugfix to support postgres15
Signed-off-by: Vitor Mattos <vitor@php.rio> Signed-off-by: Simon L <szaimen@e.mail.de> Co-Authored-By: Joas Schilling <213943+nickvergessen@users.noreply.github.com>
1 parent 9d45845 commit eb7b682

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

.drone.yml

+39-3
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ services:
455455
image: ghcr.io/nextcloud/continuous-integration-postgres-10:postgres-10
456456
environment:
457457
POSTGRES_USER: oc_autotest
458-
POSTGRES_DB: oc_autotest_dummy
458+
POSTGRES_DB: oc_autotest
459459
POSTGRES_PASSWORD: owncloud
460460
tmpfs:
461461
- /var/lib/postgresql/data
@@ -491,7 +491,7 @@ services:
491491
image: ghcr.io/nextcloud/continuous-integration-postgres-11:postgres-11
492492
environment:
493493
POSTGRES_USER: oc_autotest
494-
POSTGRES_DB: oc_autotest_dummy
494+
POSTGRES_DB: oc_autotest
495495
POSTGRES_PASSWORD: owncloud
496496
tmpfs:
497497
- /var/lib/postgresql/data
@@ -527,7 +527,43 @@ services:
527527
image: ghcr.io/nextcloud/continuous-integration-postgres-13:postgres-13
528528
environment:
529529
POSTGRES_USER: oc_autotest
530-
POSTGRES_DB: oc_autotest_dummy
530+
POSTGRES_DB: oc_autotest
531+
POSTGRES_PASSWORD: owncloud
532+
tmpfs:
533+
- /var/lib/postgresql/data
534+
535+
trigger:
536+
branch:
537+
- master
538+
- stable*
539+
event:
540+
- pull_request
541+
- push
542+
543+
---
544+
kind: pipeline
545+
name: postgres15-php8.0
546+
547+
steps:
548+
- name: submodules
549+
image: ghcr.io/nextcloud/continuous-integration-alpine-git:latest
550+
commands:
551+
- git submodule update --init
552+
- name: postgres-php8.0
553+
image: ghcr.io/nextcloud/continuous-integration-php8.0:latest
554+
commands:
555+
- bash tests/drone-run-php-tests.sh || exit 0
556+
- sleep 10 # gives the database enough time to initialize
557+
- POSTGRES=15 NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh pgsql
558+
559+
services:
560+
- name: cache
561+
image: ghcr.io/nextcloud/continuous-integration-redis:latest
562+
- name: postgres-15
563+
image: ghcr.io/nextcloud/continuous-integration-postgres-15:latest
564+
environment:
565+
POSTGRES_USER: oc_autotest
566+
POSTGRES_DB: oc_autotest
531567
POSTGRES_PASSWORD: owncloud
532568
tmpfs:
533569
- /var/lib/postgresql/data

lib/private/Setup/PostgreSQL.php

+11
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public function setupDatabase($username) {
6262
}
6363

6464
if ($canCreateRoles) {
65+
$connectionMainDatabase = $this->connect();
6566
//use the admin login data for the new database user
6667

6768
//add prefix to the postgresql user name to prevent collisions
@@ -70,6 +71,16 @@ public function setupDatabase($username) {
7071
$this->dbPassword = \OC::$server->getSecureRandom()->generate(30, ISecureRandom::CHAR_ALPHANUMERIC);
7172

7273
$this->createDBUser($connection);
74+
75+
// Go to the main database and grant create on the public schema
76+
// The code below is implemented to make installing possible with PostgreSQL version 15:
77+
// https://www.postgresql.org/docs/release/15.0/
78+
// From the release notes: For new databases having no need to defend against insider threats, granting CREATE permission will yield the behavior of prior releases
79+
// Therefore we assume that the database is only used by one user/service which is Nextcloud
80+
// Additional services should get installed in a separate database in order to stay secure
81+
// Also see https://www.postgresql.org/docs/15/ddl-schemas.html#DDL-SCHEMAS-PATTERNS
82+
$connectionMainDatabase->executeQuery('GRANT CREATE ON SCHEMA public TO ' . addslashes($this->dbUser));
83+
$connectionMainDatabase->close();
7384
}
7485

7586
$this->config->setValues([

0 commit comments

Comments
 (0)