installer postgresql
This commit is contained in:
@@ -240,6 +240,11 @@ class Binding implements BindingProcessor
|
||||
'Espo\\ORM\\PDO\\PDOProvider',
|
||||
'Espo\\ORM\\PDO\\DefaultPDOProvider'
|
||||
);
|
||||
|
||||
$binder->bindImplementation(
|
||||
'Espo\\Core\\Utils\\Database\\ConfigDataProvider',
|
||||
'Espo\\Core\\Utils\\Database\\DefaultConfigDataProvider'
|
||||
);
|
||||
}
|
||||
|
||||
private function bindMisc(Binder $binder): void
|
||||
|
||||
@@ -29,16 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Utils\Database;
|
||||
|
||||
use Espo\Core\Utils\Config;
|
||||
|
||||
class ConfigDataProvider
|
||||
interface ConfigDataProvider
|
||||
{
|
||||
private const DEFAULT_PLATFORM = 'Mysql';
|
||||
|
||||
public function __construct(private Config $config) {}
|
||||
|
||||
public function getPlatform(): string
|
||||
{
|
||||
return $this->config->get('database.platform') ?? self::DEFAULT_PLATFORM;
|
||||
}
|
||||
public function getPlatform(): string;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Utils\Database;
|
||||
|
||||
use Espo\Core\Utils\Config;
|
||||
|
||||
class DefaultConfigDataProvider implements ConfigDataProvider
|
||||
{
|
||||
private const DEFAULT_PLATFORM = 'Mysql';
|
||||
|
||||
public function __construct(private Config $config) {}
|
||||
|
||||
public function getPlatform(): string
|
||||
{
|
||||
return $this->config->get('database.platform') ?? self::DEFAULT_PLATFORM;
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,7 @@ return [
|
||||
'internalOutboundEmailFromAddress',
|
||||
'requiredPhpVersion',
|
||||
'requiredMysqlVersion',
|
||||
'requiredPostgresqlVersion',
|
||||
'recommendedMysqlParams',
|
||||
'requiredPhpLibs',
|
||||
'recommendedPhpLibs',
|
||||
@@ -270,6 +271,7 @@ return [
|
||||
'requiredMysqlVersion' => '5.7.0',
|
||||
'recommendedMysqlParams' => [],
|
||||
'requiredMariadbVersion' => '10.2.2',
|
||||
'requiredPostgresqlVersion' => '15.0',
|
||||
'recommendedMariadbParams' => [],
|
||||
/** Max execution time (in seconds) allocated for a single job. If exceeded then set to Failed.*/
|
||||
'jobPeriod' => 7800,
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\Installer;
|
||||
|
||||
use Espo\Core\Utils\Database\ConfigDataProvider;
|
||||
|
||||
class DatabaseConfigDataProvider implements ConfigDataProvider
|
||||
{
|
||||
public function __construct(
|
||||
private string $platform
|
||||
) {}
|
||||
|
||||
public function getPlatform(): string
|
||||
{
|
||||
return $this->platform;
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ use Espo\Core\Container;
|
||||
use Espo\Core\DataManager;
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\Core\ORM\DatabaseParamsFactory;
|
||||
use Espo\Core\Utils\Database\ConfigDataProvider;
|
||||
use Espo\Core\Utils\Database\Dbal\ConnectionFactoryFactory;
|
||||
use Espo\Core\Utils\Id\RecordIdGenerator;
|
||||
use Espo\Core\Utils\ScheduledJob as ScheduledJobUtil;
|
||||
@@ -52,6 +53,7 @@ use Espo\Entities\Job;
|
||||
use Espo\Entities\ScheduledJob;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use Espo\Tools\Installer\DatabaseConfigDataProvider;
|
||||
|
||||
class Installer
|
||||
{
|
||||
@@ -299,11 +301,20 @@ class Installer
|
||||
|
||||
public function getSystemRequirementList($type, $requiredOnly = false, array $additionalData = null)
|
||||
{
|
||||
$platform = $additionalData['databaseParams']['platform'] ?? 'Mysql';
|
||||
|
||||
$dbConfigDataProvider = new DatabaseConfigDataProvider($platform);
|
||||
|
||||
/** @var SystemRequirements $systemRequirementManager */
|
||||
$systemRequirementManager = $this->app
|
||||
->getContainer()
|
||||
->getByClass(InjectableFactory::class)
|
||||
->create(SystemRequirements::class);
|
||||
->createWithBinding(
|
||||
SystemRequirements::class,
|
||||
BindingContainerBuilder::create()
|
||||
->bindInstance(ConfigDataProvider::class, $dbConfigDataProvider)
|
||||
->build()
|
||||
);
|
||||
|
||||
return $systemRequirementManager->getRequiredListByType($type, $requiredOnly, $additionalData);
|
||||
}
|
||||
|
||||
@@ -40,15 +40,16 @@ $database = [
|
||||
'dbname' => $_SESSION['install']['db-name'],
|
||||
'user' => $_SESSION['install']['db-user-name'],
|
||||
'password' => $_SESSION['install']['db-user-password'],
|
||||
'platform' => $_SESSION['install']['db-platform'],
|
||||
];
|
||||
|
||||
$host = $_SESSION['install']['host-name'];
|
||||
|
||||
if (strpos($host,':') === false) {
|
||||
if (!str_contains($host, ':')) {
|
||||
$host .= ":";
|
||||
}
|
||||
|
||||
list($database['host'], $database['port']) = explode(':', $host);
|
||||
[$database['host'], $database['port']] = explode(':', $host);
|
||||
|
||||
$saveData = [
|
||||
'database' => $database,
|
||||
|
||||
@@ -29,7 +29,10 @@
|
||||
|
||||
ob_start();
|
||||
|
||||
$result = array('success' => true, 'errors' => array());
|
||||
$result = [
|
||||
'success' => true,
|
||||
'errors' => [],
|
||||
];
|
||||
|
||||
$phpRequiredList = $installer->getSystemRequirementList('php', true);
|
||||
|
||||
@@ -40,11 +43,13 @@ foreach ($phpRequiredList as $name => $details) {
|
||||
case 'version':
|
||||
$result['success'] = false;
|
||||
$result['errors']['phpVersion'] = $details['required'];
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$result['success'] = false;
|
||||
$result['errors']['phpRequires'][] = $name;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -52,14 +57,22 @@ foreach ($phpRequiredList as $name => $details) {
|
||||
|
||||
$allPostData = $postData->getAll();
|
||||
|
||||
if ($result['success'] && !empty($allPostData['dbName']) && !empty($allPostData['hostName']) && !empty($allPostData['dbUserName'])) {
|
||||
if (
|
||||
$result['success'] &&
|
||||
!empty($allPostData['dbName']) &&
|
||||
!empty($allPostData['hostName']) &&
|
||||
!empty($allPostData['dbUserName'])
|
||||
) {
|
||||
$connect = false;
|
||||
|
||||
$dbName = trim($allPostData['dbName']);
|
||||
if (strpos($allPostData['hostName'],':') === false) {
|
||||
|
||||
if (!str_contains($allPostData['hostName'], ':')) {
|
||||
$allPostData['hostName'] .= ":";
|
||||
}
|
||||
list($hostName, $port) = explode(':', trim($allPostData['hostName']));
|
||||
|
||||
[$hostName, $port] = explode(':', trim($allPostData['hostName']));
|
||||
|
||||
$dbUserName = trim($allPostData['dbUserName']);
|
||||
$dbUserPass = trim($allPostData['dbUserPass']);
|
||||
|
||||
@@ -67,7 +80,10 @@ if ($result['success'] && !empty($allPostData['dbName']) && !empty($allPostData[
|
||||
$port = null;
|
||||
}
|
||||
|
||||
$platform = $allPostData['dbPlatform'] ?? 'Mysql';
|
||||
|
||||
$databaseParams = [
|
||||
'platform' => $platform,
|
||||
'host' => $hostName,
|
||||
'port' => $port,
|
||||
'user' => $dbUserName,
|
||||
@@ -79,7 +95,8 @@ if ($result['success'] && !empty($allPostData['dbName']) && !empty($allPostData[
|
||||
|
||||
try {
|
||||
$installer->checkDatabaseConnection($databaseParams, true);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$isConnected = false;
|
||||
$result['success'] = false;
|
||||
$result['errors']['dbConnect']['errorCode'] = $e->getCode();
|
||||
@@ -92,16 +109,17 @@ if ($result['success'] && !empty($allPostData['dbName']) && !empty($allPostData[
|
||||
|
||||
foreach ($databaseRequiredList as $name => $details) {
|
||||
if (!$details['acceptable']) {
|
||||
|
||||
switch ($details['type']) {
|
||||
case 'version':
|
||||
$result['success'] = false;
|
||||
$result['errors'][$name] = $details['required'];
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$result['success'] = false;
|
||||
$result['errors'][$name][] = $name;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ $dbConfig = [
|
||||
'dbname' => $installData['db-name'],
|
||||
'user' => $installData['db-user-name'],
|
||||
'password' => $installData['db-user-password'],
|
||||
'platform' => $installData['db-platform']
|
||||
];
|
||||
|
||||
$mysqlRequirementList = $installer->getSystemRequirementList('database', false, ['databaseParams' => $dbConfig]);
|
||||
|
||||
@@ -43,30 +43,39 @@ foreach ($clearedCookieList as $cookieName) {
|
||||
|
||||
$config = $installer->getConfig();
|
||||
|
||||
$fields = array(
|
||||
'db-driver' => array(
|
||||
$fields = [
|
||||
'db-platform' => [
|
||||
'default' => $config->get('database.platform', 'Mysql'),
|
||||
],
|
||||
'db-driver' => [
|
||||
'default' => $config->get('database.driver', ''),
|
||||
),
|
||||
'db-name' => array(
|
||||
],
|
||||
'db-name' => [
|
||||
'default' => $config->get('database.dbname', ''),
|
||||
),
|
||||
'host-name' => array(
|
||||
'default' => $config->get('database.host', '') . ($config->get('database.port') ? ':' . $config->get('database.port') : ''),
|
||||
),
|
||||
'db-user-name' => array(
|
||||
],
|
||||
'host-name' => [
|
||||
'default' => $config->get('database.host', '') .
|
||||
($config->get('database.port') ? ':' . $config->get('database.port') : ''),
|
||||
],
|
||||
'db-user-name' => [
|
||||
'default' => $config->get('database.user', ''),
|
||||
),
|
||||
'db-user-password' => array(
|
||||
//'default' => $config->get('database.password', ''),
|
||||
),
|
||||
);
|
||||
],
|
||||
'db-user-password' => [],
|
||||
];
|
||||
|
||||
foreach ($fields as $fieldName => $field) {
|
||||
if (isset($_SESSION['install'][$fieldName])) {
|
||||
$fields[$fieldName]['value'] = $_SESSION['install'][$fieldName];
|
||||
} else {
|
||||
$fields[$fieldName]['value'] = isset($field['default']) ? $field['default'] : '';
|
||||
$fields[$fieldName]['value'] = $field['default'] ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
$platforms = [
|
||||
'Mysql' => 'MySQL',
|
||||
'Postgresql' => 'PostgreSQL',
|
||||
];
|
||||
|
||||
$smarty->assign('platforms', $platforms);
|
||||
|
||||
$smarty->assign('fields', $fields);
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
"fields": {
|
||||
"Choose your language": "Choose your language",
|
||||
"Database Name": "Database Name",
|
||||
"Platform": "Platform",
|
||||
"Host Name": "Host Name",
|
||||
"Port": "Port",
|
||||
"Database User Name": "Database User Name",
|
||||
|
||||
@@ -6,6 +6,23 @@
|
||||
<div class="row">
|
||||
<div class=" col-md-6">
|
||||
<div class="row">
|
||||
<div class="cell cell-db-platform col-sm-12 form-group">
|
||||
<label class="field-label-db-platform control-label">{$langs['fields']['Platform']}</label>
|
||||
<div class="field field-db-platform">
|
||||
<select
|
||||
name="db-platform"
|
||||
class="main-element form-control"
|
||||
>
|
||||
{foreach from=$platforms item=lbl key=val}
|
||||
{if $val == $fields['db-platform'].value}
|
||||
<option selected="selected" value="{$val}">{$lbl}</option>
|
||||
{else}
|
||||
<option value="{$val}">{$lbl}</option>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell cell-website col-sm-12 form-group">
|
||||
<label class="field-label-website control-label">{$langs['fields']['Host Name']} *</label>
|
||||
<div class="field field-website">
|
||||
|
||||
@@ -363,6 +363,7 @@ InstallScript.prototype.finish = function() {
|
||||
}
|
||||
|
||||
InstallScript.prototype.setConnSett = function() {
|
||||
this.connSett.dbPlatform = $('[name="db-platform"]').val();
|
||||
this.connSett.dbName = $('[name="db-name"]').val();
|
||||
this.connSett.hostName = $('[name="host-name"]').val();
|
||||
this.connSett.dbUserName = $('[name="db-user-name"]').val();
|
||||
|
||||
Reference in New Issue
Block a user