mirror of
https://github.com/friendica/friendica
synced 2025-04-23 10:30:11 +00:00
Split DBStructure & View to avoid DB-calls and dependencies for basic operations
- new "Definition" classes vor DB and Views - new "Writer" classes to create SQL definitions for DB and Views - DBStructure & View are responsible to execute DB-querys
This commit is contained in:
parent
a2c929d128
commit
a910fd8864
30 changed files with 898 additions and 608 deletions
|
@ -25,6 +25,12 @@ use Friendica\Core\Config\ValueObject\Cache;
|
|||
use Friendica\Core\Update;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\Database\Definition\DbaDefinition;
|
||||
use Friendica\Database\Definition\ViewDefinition;
|
||||
use Friendica\Util\BasePath;
|
||||
use Friendica\Util\Writer\DbaDefinitionSqlWriter;
|
||||
use Friendica\Util\Writer\DocWriter;
|
||||
use Friendica\Util\Writer\ViewDefinitionSqlWriter;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
|
@ -42,6 +48,18 @@ class DatabaseStructure extends \Asika\SimpleConsole\Console
|
|||
* @var Cache
|
||||
*/
|
||||
private $configCache;
|
||||
/**
|
||||
* @var DbaDefinition
|
||||
*/
|
||||
private $dbaDefinition;
|
||||
/**
|
||||
* @var ViewDefinition
|
||||
*/
|
||||
private $viewDefinition;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $basePath;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
|
@ -71,12 +89,15 @@ HELP;
|
|||
return $help;
|
||||
}
|
||||
|
||||
public function __construct(Database $dba, Cache $configCache, $argv = null)
|
||||
public function __construct(Database $dba, DbaDefinition $dbaDefinition, ViewDefinition $viewDefinition, BasePath $basePath, Cache $configCache, $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->dba = $dba;
|
||||
$this->dbaDefinition = $dbaDefinition;
|
||||
$this->viewDefinition = $viewDefinition;
|
||||
$this->configCache = $configCache;
|
||||
$this->basePath = $basePath->getPath();
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
|
@ -120,10 +141,9 @@ HELP;
|
|||
$output = ob_get_clean();
|
||||
break;
|
||||
case "dumpsql":
|
||||
DBStructure::writeStructure();
|
||||
ob_start();
|
||||
DBStructure::printStructure($basePath);
|
||||
$output = ob_get_clean();
|
||||
DocWriter::writeDbDefinition($this->dbaDefinition, $this->basePath);
|
||||
$output = DbaDefinitionSqlWriter::create($this->dbaDefinition);
|
||||
$output .= ViewDefinitionSqlWriter::create($this->viewDefinition);
|
||||
break;
|
||||
case "toinnodb":
|
||||
ob_start();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue