mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 15:06:06 +00:00
changed rebuild path to /admin/rebuild
This commit is contained in:
37
application/Espo/Controllers/Admin.php
Normal file
37
application/Espo/Controllers/Admin.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use \Espo\Core\Exceptions\Error,
|
||||
\Espo\Core\Exceptions\Forbidden;
|
||||
|
||||
class Admin extends \Espo\Core\Controllers\Base
|
||||
{
|
||||
|
||||
public function __construct(Container $container, ServiceFactory $serviceFactory)
|
||||
{
|
||||
parent::__construct($container, $serviceFactory);
|
||||
|
||||
if (!$this->getUser()->isAdmin()) {
|
||||
throw new Forbidden("You do not have access to this area");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function actionRebuild($params, $data)
|
||||
{
|
||||
try{
|
||||
$result = $this->getContainer()->get('schema')->rebuild();
|
||||
} catch (\Exception $e) {
|
||||
$result = false;
|
||||
$GLOBALS['log']->add('EXCEPTION', 'Fault to rebuild database schema'.'. Details: '.$e->getMessage());
|
||||
}
|
||||
|
||||
if ($result === false) {
|
||||
throw new Error("Error while rebuilding database");
|
||||
}
|
||||
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class Rebuild extends \Espo\Core\Controllers\Base
|
||||
{
|
||||
|
||||
public function actionRead($params, $data)
|
||||
{
|
||||
try{
|
||||
$result = $this->getContainer()->get('schema')->rebuild();
|
||||
} catch (\Exception $e) {
|
||||
$result = false;
|
||||
$GLOBALS['log']->add('EXCEPTION', 'Fault to rebuild database schema'.'. Details: '.$e->getMessage());
|
||||
}
|
||||
|
||||
if ($result === false) {
|
||||
throw new Error("Error while rebuilding database");
|
||||
}
|
||||
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -134,7 +134,7 @@ class Application
|
||||
}
|
||||
$controllerParams[$key] = $value;
|
||||
}
|
||||
|
||||
|
||||
$controllerName = ucfirst($controllerParams['controller']);
|
||||
|
||||
if (!empty($controllerParams['action'])) {
|
||||
@@ -148,7 +148,7 @@ class Application
|
||||
$controllerManager = new \Espo\Core\ControllerManager($container, $serviceFactory);
|
||||
$result = $controllerManager->process($controllerName, $actionName, $params, $data);
|
||||
$container->get('output')->render($result);
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
$container->get('output')->processError($e->getMessage(), $e->getCode());
|
||||
}
|
||||
|
||||
@@ -229,9 +229,10 @@ EOT;
|
||||
);
|
||||
})->via('PATCH');
|
||||
|
||||
$this->getSlim()->get('/app/rebuild/', function() {
|
||||
$this->getSlim()->get('/admin/rebuild/', function() {
|
||||
return array(
|
||||
'controller' => 'Rebuild',
|
||||
'controller' => 'Admin',
|
||||
'action' => 'rebuild',
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -81,13 +81,14 @@ class Converter
|
||||
|
||||
$databaseMeta = $this->getOrmConverter()->prepare($databaseMeta);
|
||||
|
||||
$schema = $this->getSchemaConverter()->process($databaseMeta, $entityDefs);
|
||||
$this->setSchemaFromMetadata($schema);
|
||||
|
||||
//save database meta to a file espoMetadata.php
|
||||
$result = $this->getMetadata()->setEspoMetadata($databaseMeta);
|
||||
|
||||
|
||||
$schema = $this->getSchemaConverter()->process($databaseMeta, $entityDefs);
|
||||
$this->setSchemaFromMetadata($schema);
|
||||
|
||||
|
||||
$GLOBALS['log']->add('Debug', 'Converter:process() - End: converting metadata to orm format and database schema, result=['.$result.']');
|
||||
|
||||
return $result;
|
||||
|
||||
@@ -19,6 +19,10 @@ class Orm
|
||||
'int' => 11,
|
||||
);
|
||||
|
||||
protected $defaultValue = array(
|
||||
'bool' => false,
|
||||
);
|
||||
|
||||
/*
|
||||
* //pair espo:doctrine
|
||||
*/
|
||||
@@ -95,9 +99,8 @@ class Orm
|
||||
$fieldParams['len'] = $this->defaultLength['varchar'];
|
||||
break;
|
||||
|
||||
case 'array':
|
||||
case 'json_array':
|
||||
unset($fieldParams['default']); //for db type TEXT can't be defined a default value
|
||||
case 'bool':
|
||||
$fieldParams['default'] = isset($fieldParams['default']) ? (bool) $fieldParams['default'] : $this->defaultValue['bool'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -165,7 +168,7 @@ class Orm
|
||||
if (!isset($outputMeta['deleted'])) {
|
||||
$outputMeta['deleted'] = array(
|
||||
'type' => Entity::BOOL,
|
||||
'default' => 0,
|
||||
'default' => false,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,10 +48,6 @@ class Schema
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($fieldParams['type'] == 'id') {
|
||||
$primaryColumns[] = Util::toUnderScore($fieldName);
|
||||
}
|
||||
|
||||
switch ($fieldParams['type']) {
|
||||
case 'id':
|
||||
$primaryColumns[] = Util::toUnderScore($fieldName);
|
||||
|
||||
Reference in New Issue
Block a user