Issues (496)

lib/Migration/Version3006Date20210601200000.php (4 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\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...
17
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...
18
19
/**
20
 * Auto-generated migration step: Please modify to your needs!
21
 * sudo -u www-data php /var/www/nextcloud/occ migrations:execute analytics 3006Date20210601200000
22
 *
23
 */
24
class Version3006Date20210601200000 extends SimpleMigrationStep
25
{
26
27
    /** @var IDBConnection */
28
    private $connection;
29
30
    public function __construct(IDBConnection $connection)
31
    {
32
        $this->connection = $connection;
33
    }
34
35
    /**
36
     * @param IOutput $output
37
     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
38
     * @param array $options
39
     */
40
    public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options)
41
    {
42
    }
43
44
    /**
45
     * @param IOutput $output
46
     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
47
     * @param array $options
48
     * @return null|ISchemaWrapper
49
     */
50
    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options)
51
    {
52
        /** @var ISchemaWrapper $schema */
53
        $schema = $schemaClosure();
54
55
        $table = $schema->getTable('analytics_share');
56
        if (!$table->hasColumn('parent')) {
57
            $table->addColumn('parent', 'integer', [
58
                'notnull' => false,
59
            ]);
60
        }
61
62
        $table = $schema->getTable('analytics_dataset');
63
        if (!$table->hasColumn('refresh')) {
64
            $table->addColumn('refresh', 'integer', [
65
                'notnull' => false,
66
            ]);
67
        }
68
69
        return $schema;
70
    }
71
72
    /**
73
     * @param IOutput $output
74
     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
75
     * @param array $options
76
     */
77
    public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options)
78
    {
79
        $query = $this->connection->getQueryBuilder();
80
        $query->insert('analytics_whats_new')
81
            ->values([
82
                'version' => $query->createNamedParameter('3.6.0'),
83
                'data' => $query->createNamedParameter('{"changelogURL":"https:\/\/github.com\/rello\/analytics\/blob\/master\/CHANGELOG.md","whatsNew":{
84
"en":{"regular":["Text variables in reports","Customize chart colors","Automatic refresh","Data labels"],"admin":["New Features apply to users"]},
85
"de":{"regular":["Textvariablen in Berichten","Grafik-Farben anpassen","Automatischer refresh","Daten Beschriftungen"],"admin":["Nur User Features"]}
86
}}'),
87
            ])
88
            ->execute();
89
    }
90
}
91