Passed
Push — master ( c70a6b...e1aeb2 )
by Marcel
05:29 queued 16s
created

Version4012Date20231108180000   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 33
c 1
b 0
f 0
dl 0
loc 61
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A changeSchema() 0 44 2
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace OCA\Analytics\Migration;
6
7
use Closure;
8
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...
9
use OCP\IDBConnection;
0 ignored issues
show
Bug introduced by
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...
10
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...
11
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...
12
13
/**
14
 * Auto-generated migration step: Please modify to your needs!
15
 * sudo -u www-data php /var/www/nextcloud/occ migrations:execute analytics 4012Date20231108180000
16
 */
17
class Version4012Date20231108180000 extends SimpleMigrationStep
18
{
19
20
    /** @var IDBConnection */
21
    private $connection;
22
23
    public function __construct(IDBConnection $connection)
24
    {
25
        $this->connection = $connection;
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
        if (!$schema->hasTable('analytics_story')) {
40
            $table = $schema->createTable('analytics_story');
41
            $table->addColumn('id', 'integer', [
42
                'autoincrement' => true,
43
                'notnull' => true,
44
            ]);
45
            $table->addColumn('user_id', 'string', [
46
                'notnull' => true,
47
                'length' => 64,
48
            ]);
49
            $table->addColumn('name', 'string', [
50
                'notnull' => true,
51
                'length' => 64,
52
            ]);
53
            $table->addColumn('subheader', 'string', [
54
                'notnull' => false,
55
                'length' => 256,
56
            ]);
57
            $table->addColumn('type', 'integer', [
58
                'notnull' => false,
59
            ]);
60
            $table->addColumn('page', 'integer', [
61
                'notnull' => false,
62
            ]);
63
            $table->addColumn('parent', 'integer', [
64
                'notnull' => false,
65
            ]);
66
            $table->addColumn('reports', 'string', [
67
                'notnull' => false,
68
                'length' => 256,
69
            ]);
70
            $table->addColumn('layout', 'string', [
71
                'notnull' => false,
72
                'length' => 1000,
73
            ]);
74
            $table->setPrimaryKey(['id']);
75
            $table->addIndex(['user_id'], 'analytics_dataset_user_id_idx');
76
        }
77
        return $schema;
78
    }
79
}
80