Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/fact/management/PhabricatorFactManagementDestroyWorkflow.php
12256 views
1
<?php
2
3
final class PhabricatorFactManagementDestroyWorkflow
4
extends PhabricatorFactManagementWorkflow {
5
6
protected function didConstruct() {
7
$this
8
->setName('destroy')
9
->setSynopsis(pht('Destroy all facts.'))
10
->setArguments(array());
11
}
12
13
public function execute(PhutilArgumentParser $args) {
14
$console = PhutilConsole::getConsole();
15
16
$question = pht(
17
'Really destroy all facts? They will need to be rebuilt through '.
18
'analysis, which may take some time.');
19
20
$ok = $console->confirm($question, $default = false);
21
if (!$ok) {
22
return 1;
23
}
24
25
$tables = array();
26
$tables[] = new PhabricatorFactCursor();
27
28
$tables[] = new PhabricatorFactIntDatapoint();
29
30
$tables[] = new PhabricatorFactObjectDimension();
31
$tables[] = new PhabricatorFactKeyDimension();
32
33
foreach ($tables as $table) {
34
$conn = $table->establishConnection('w');
35
$name = $table->getTableName();
36
37
$console->writeOut("%s\n", pht("Destroying table '%s'...", $name));
38
39
queryfx(
40
$conn,
41
'TRUNCATE TABLE %T',
42
$name);
43
}
44
45
$console->writeOut("%s\n", pht('Done.'));
46
}
47
48
}
49
50