Issues (496)

lib/Migration/Version4001Date20220317190000.php (5 issues)

Labels
Severity
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
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\IDBConnection;
0 ignored issues
show
The type OCP\IDBConnection 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\DB\QueryBuilder\IQueryBuilder;
0 ignored issues
show
The type OCP\DB\QueryBuilder\IQueryBuilder 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
use OCP\Migration\IOutput;
0 ignored issues
show
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...
18
use OCP\Migration\SimpleMigrationStep;
0 ignored issues
show
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...
19
20
/**
21
 * Auto-generated migration step: Please modify to your needs!
22
 * sudo -u www-data php /var/www/nextcloud/occ migrations:execute analytics 4001Date20220317190000
23
 *
24
 * Deletions
25
 * dataset:
26
 * subheader, link, visual, chart*, *options, parent, type
27
 */
28
class Version4001Date20220317190000 extends SimpleMigrationStep
29
{
30
31
    /** @var IDBConnection */
32
    private $connection;
33
34
    public function __construct(IDBConnection $connection)
35
    {
36
        $this->connection = $connection;
37
    }
38
39
    /**
40
     * @param IOutput $output
41
     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
42
     * @param array $options
43
     */
44
    public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options)
45
    {
46
    }
47
48
    /**
49
     * @param IOutput $output
50
     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
51
     * @param array $options
52
     * @return null|ISchemaWrapper
53
     */
54
    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options)
55
    {
56
        /** @var ISchemaWrapper $schema */
57
        $schema = $schemaClosure();
58
59
        $table = $schema->getTable('analytics_share');
60
        if (!$table->hasColumn('domain')) {
61
            $table->addColumn('domain', 'string', [
62
                'notnull' => false,
63
                'length' => 256,
64
            ]);
65
        }
66
        if ($table->hasIndex('analytics_share_dataset_idx')) {
67
            $table->dropIndex('analytics_share_dataset_idx');
68
        }
69
        if ($table->hasColumn('dataset')) {
70
            $table->dropColumn('dataset');
71
        }
72
73
        $table = $schema->getTable('analytics_threshold');
74
        if ($table->hasIndex('analytics_threshold_dset_idx')) {
75
            $table->dropIndex('analytics_threshold_dset_idx');
76
        }
77
        if ($table->hasColumn('dataset')) {
78
            $table->dropColumn('dataset');
79
        }
80
        return $schema;
81
    }
82
83
    /**
84
     * @param IOutput $output
85
     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
86
     * @param array $options
87
     */
88
    public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options)
89
    {
90
    }
91
}