1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace OCA\Analytics\Migration; |
6
|
|
|
|
7
|
|
|
use Closure; |
8
|
|
|
use Doctrine\DBAL\Types\Type; |
|
|
|
|
9
|
|
|
use OCP\DB\ISchemaWrapper; |
10
|
|
|
use OCP\IDBConnection; |
11
|
|
|
use OCP\Migration\IOutput; |
12
|
|
|
use OCP\Migration\SimpleMigrationStep; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Auto-generated migration step: Please modify to your needs! |
16
|
|
|
* sudo -u www-data php /var/www/nextcloud/occ migrations:execute analytics 020500Date20200815180000 |
17
|
|
|
*/ |
18
|
|
|
class Version020500Date20200815180000 extends SimpleMigrationStep |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
/** @var IDBConnection */ |
22
|
|
|
private $connection; |
23
|
|
|
|
24
|
|
|
public function __construct(IDBConnection $connection) |
25
|
|
|
{ |
26
|
|
|
$this->connection = $connection; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param IOutput $output |
31
|
|
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
32
|
|
|
* @param array $options |
33
|
|
|
*/ |
34
|
|
|
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) |
35
|
|
|
{ |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param IOutput $output |
40
|
|
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
41
|
|
|
* @param array $options |
42
|
|
|
* @return null|ISchemaWrapper |
43
|
|
|
*/ |
44
|
|
|
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) |
45
|
|
|
{ |
46
|
|
|
/** @var Schema $schema */ |
47
|
|
|
$schema = $schemaClosure(); |
48
|
|
|
$table = $schema->getTable('analytics_facts'); |
49
|
|
|
|
50
|
|
|
$table->addColumn('value', Type::DECIMAL, [ |
51
|
|
|
'notnull' => false, |
52
|
|
|
'precision' => 15, |
53
|
|
|
'scale' => 2, |
54
|
|
|
'default' => 0, |
55
|
|
|
]); |
56
|
|
|
|
57
|
|
|
$table->addColumn('timestamp', Type::INTEGER, [ |
58
|
|
|
'notnull' => false, |
59
|
|
|
'default' => 0, |
60
|
|
|
]); |
61
|
|
|
|
62
|
|
|
|
63
|
|
|
$table = $schema->getTable('analytics_dataset'); |
64
|
|
|
|
65
|
|
|
$table->addColumn('value', Type::STRING, [ |
66
|
|
|
'notnull' => false, |
67
|
|
|
'length' => 64, |
68
|
|
|
]); |
69
|
|
|
|
70
|
|
|
return $schema; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param IOutput $output |
75
|
|
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
76
|
|
|
* @param array $options |
77
|
|
|
*/ |
78
|
|
|
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) |
79
|
|
|
{ |
80
|
|
|
$query = $this->connection->getQueryBuilder(); |
81
|
|
|
$query->update('analytics_facts') |
82
|
|
|
->set('value', 'dimension3'); |
83
|
|
|
$query->execute(); |
84
|
|
|
|
85
|
|
|
$query2 = $this->connection->getQueryBuilder(); |
86
|
|
|
$query2->update('analytics_dataset') |
87
|
|
|
->set('value', 'dimension3'); |
88
|
|
|
$query2->execute(); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths