Passed
Push — master ( 9002ff...62782a )
by Marcel
04:34
created

Version4015Date20240714200000   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 25
dl 0
loc 53
rs 10
c 1
b 0
f 0
wmc 11

2 Methods

Rating   Name   Duplication   Size   Complexity  
D changeSchema() 0 41 10
A __construct() 0 2 1
1
<?php
2
/**
3
 * Analytics
4
 *
5
 * SPDX-FileCopyrightText: 2019-2022 Marcel Scherello
6
 * SPDX-License-Identifier: AGPL-3.0-or-later
7
 */
8
9
declare(strict_types=1);
10
11
namespace OCA\Analytics\Migration;
12
13
use Closure;
14
use OCP\DB\ISchemaWrapper;
0 ignored issues
show
Bug introduced by
The type OCP\DB\ISchemaWrapper was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use OCP\Migration\IOutput;
0 ignored issues
show
Bug introduced by
The type OCP\Migration\IOutput was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use OCP\Migration\SimpleMigrationStep;
0 ignored issues
show
Bug introduced by
The type OCP\Migration\SimpleMigrationStep was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
18
/**
19
 * Auto-generated migration step: Please modify to your needs!
20
 * sudo -u www-data php occ migrations:execute analytics 4015Date20240714200000
21
 */
22
class Version4015Date20240714200000 extends SimpleMigrationStep
23
{
24
    public function __construct()
25
    {
26
    }
27
28
    /**
29
     * @param IOutput $output
30
     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
31
     * @param array $options
32
     * @return null|ISchemaWrapper
33
     */
34
    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options)
35
    {
36
        /** @var ISchemaWrapper $schema */
37
        $schema = $schemaClosure();
38
39
        $table = $schema->getTable('analytics_dataset');
40
        if (!$table->hasColumn('ai_index')) {
41
            $table->addColumn('ai_index', 'integer', [
42
                'notnull' => false
43
            ]);
44
        }
45
		if ($table->hasColumn('chartoptions')) {
46
			$table->dropColumn('chartoptions');
47
		}
48
		if ($table->hasColumn('dataoptions')) {
49
			$table->dropColumn('dataoptions');
50
		}
51
		if ($table->hasColumn('filteroptions')) {
52
			$table->dropColumn('filteroptions');
53
		}
54
		if ($table->hasColumn('refresh')) {
55
			$table->dropColumn('refresh');
56
		}
57
		if ($table->hasColumn('link')) {
58
			$table->dropColumn('link');
59
		}
60
		if ($table->hasColumn('visualization')) {
61
			$table->dropColumn('visualization');
62
		}
63
		if ($table->hasColumn('chart')) {
64
			$table->dropColumn('chart');
65
		}
66
67
		$table = $schema->getTable('analytics_share');
68
		if (!$table->hasColumn('panorama')) {
69
			$table->addColumn('panorama', 'integer', [
70
				'notnull' => false,
71
			]);
72
		}
73
74
		return $schema;
75
    }
76
}