1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Zemit Framework. |
5
|
|
|
* |
6
|
|
|
* (c) Zemit Team <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE.txt |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Zemit\Modules\Cli\Tasks; |
13
|
|
|
|
14
|
|
|
use Zemit\Bootstrap\Deployment; |
15
|
|
|
use Zemit\Modules\Cli\Task; |
16
|
|
|
use Zemit\Modules\Cli\Tasks\Traits\DatabaseTrait; |
17
|
|
|
use Zemit\Utils; |
18
|
|
|
|
19
|
|
|
class DatabaseTask extends Task |
20
|
|
|
{ |
21
|
|
|
use DatabaseTrait; |
22
|
|
|
|
23
|
|
|
public string $cliDoc = <<<DOC |
24
|
|
|
Usage: |
25
|
|
|
php zemit cli database <action> [<params> ...] |
26
|
|
|
|
27
|
|
|
Options: |
28
|
|
|
task: database |
29
|
|
|
action: drop, truncate, fixEngine, insert, optimize, analyze |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
DOC; |
33
|
|
|
|
34
|
|
|
public ?array $drop = null; |
35
|
|
|
public ?array $truncate = null; |
36
|
|
|
public ?array $engine = null; |
37
|
|
|
public ?array $insert = null; |
38
|
|
|
public ?array $optimize = null; |
39
|
|
|
public ?array $analyze = null; |
40
|
|
|
|
41
|
|
|
public function initialize(): void |
42
|
|
|
{ |
43
|
|
|
Utils::setUnlimitedRuntime(); |
44
|
|
|
|
45
|
|
|
$deploymentConfig = new Deployment(); |
46
|
|
|
$this->drop ??= $deploymentConfig->pathToArray('drop'); |
47
|
|
|
$this->truncate ??= $deploymentConfig->pathToArray('truncate'); |
48
|
|
|
$this->engine ??= $deploymentConfig->pathToArray('engine'); |
49
|
|
|
$this->insert ??= $deploymentConfig->pathToArray('insert'); |
50
|
|
|
$this->optimize ??= $deploymentConfig->pathToArray('optimize'); |
51
|
|
|
$this->analyze ??= $deploymentConfig->pathToArray('analyze'); |
52
|
|
|
|
53
|
|
|
$this->addModelsPermissions(); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|