From 8d1f75262021efd512344122718ea024b3bb8cdd Mon Sep 17 00:00:00 2001 From: Frederic Alix <9548962+fredericalix@users.noreply.github.com> Date: Sat, 25 Sep 2021 04:56:44 +0200 Subject: [PATCH] feat: add possibility to set PostgreSQL schema other than public (#4161) --- config.sample.yml | 3 +++ server/core/db.js | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/config.sample.yml b/config.sample.yml index c149f702..316dd603 100644 --- a/config.sample.yml +++ b/config.sample.yml @@ -43,6 +43,9 @@ db: # pfx: path/to/cert.pfx # passphrase: xyz123 + # Optional - PostgreSQL only: + schema: public + # SQLite only: storage: path/to/database.sqlite diff --git a/server/core/db.js b/server/core/db.js index f1ac88b3..2d614c55 100644 --- a/server/core/db.js +++ b/server/core/db.js @@ -138,6 +138,10 @@ module.exports = { switch (WIKI.config.db.type) { case 'postgres': await conn.query(`set application_name = 'Wiki.js'`) + // -> Set schema if it's not public + if (WIKI.config.db.schema && WIKI.config.db.schema !== 'public') { + await conn.query(`set search_path TO ${WIKI.config.db.schema}, public;`) + } done() break case 'mysql':