aboutsummaryrefslogtreecommitdiff
path: root/lib/lib_install.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-12-30 13:17:09 +0100
committerGravatar GitHub <noreply@github.com> 2019-12-30 13:17:09 +0100
commit94db40a742dded71f80f85821cd3da5f462a4757 (patch)
tree99682a3b4ac658275d337a763803aa134193f750 /lib/lib_install.php
parent03ddcf0772f77f8e67edcc43a71cb8d01c18a3ff (diff)
Fix PostgreSQL install (#2735)
* Fix PostgreSQL install Fix https://github.com/FreshRSS/FreshRSS/issues/2732 When username is different from database name * Add more comments https://github.com/FreshRSS/FreshRSS/pull/2735/files/2b7807d1b3fdd0dc34538faad465934fb737fa3a#r361846714
Diffstat (limited to 'lib/lib_install.php')
-rw-r--r--lib/lib_install.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/lib_install.php b/lib/lib_install.php
index 5ea1b4d2b..29dbc7b67 100644
--- a/lib/lib_install.php
+++ b/lib/lib_install.php
@@ -87,15 +87,19 @@ function initDb() {
$db['pdo_options'][PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$conf->db = $db; //TODO: Remove this Minz limitation "Indirect modification of overloaded property"
+ //Attempt to auto-create database if it does not already exist
if ($db['type'] !== 'sqlite') {
Minz_ModelPdo::$usesSharedPdo = false;
$dbBase = isset($db['base']) ? $db['base'] : '';
- $db['base'] = '';
+ //For first connection, use default database for PostgreSQL, empty database for MySQL / MariaDB:
+ $db['base'] = $db['type'] === 'pgsql' ? 'postgres' : '';
$conf->db = $db;
//First connection without database name to create the database
$databaseDAO = FreshRSS_Factory::createDatabaseDAO();
+ //Restore final database parameters for auto-creation and for future connections
$db['base'] = $dbBase;
$conf->db = $db;
+ //Perfom database auto-creation
$databaseDAO->create();
}