Passed
Push — master ( 192056...6c6baa )
by Marcel
05:20 queued 14s
created

Version4012Date20231108180000::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 2
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace OCA\Analytics\Migration;
6
7
use Closure;
8
use Doctrine\DBAL\Types\Type;
0 ignored issues
show
Bug introduced by
The type Doctrine\DBAL\Types\Type 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\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...
10
use OCP\DB\Types;
0 ignored issues
show
Bug introduced by
The type OCP\DB\Types 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\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...
12
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...
13
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...
14
15
/**
16
 * Auto-generated migration step: Please modify to your needs!
17
 * sudo -u www-data php occ migrations:execute analytics 4012Date20231108180000
18
 */
19
class Version4012Date20231108180000 extends SimpleMigrationStep
20
{
21
22
    /** @var IDBConnection */
23
    private $connection;
24
25
    public function __construct(IDBConnection $connection)
26
    {
27
        $this->connection = $connection;
28
    }
29
30
    /**
31
     * @param IOutput $output
32
     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
33
     * @param array $options
34
     * @return null|ISchemaWrapper
35
     */
36
    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options)
37
    {
38
        /** @var ISchemaWrapper $schema */
39
        $schema = $schemaClosure();
40
41
        if (!$schema->hasTable('analytics_panorama')) {
42
            $table = $schema->createTable('analytics_panorama');
43
            $table->addColumn('id', 'integer', [
44
                'autoincrement' => true,
45
                'notnull' => true,
46
            ]);
47
            $table->addColumn('user_id', 'string', [
48
                'notnull' => true,
49
                'length' => 64,
50
            ]);
51
            $table->addColumn('name', 'string', [
52
                'notnull' => true,
53
                'length' => 64,
54
            ]);
55
            $table->addColumn('type', 'integer', [
56
                'notnull' => false,
57
            ]);
58
            $table->addColumn('parent', 'integer', [
59
                'notnull' => false,
60
            ]);
61
            $table->addColumn('pages', 'text', [
62
                'notnull' => false,
63
            ]);
64
            $table->setPrimaryKey(['id']);
65
            $table->addIndex(['user_id'], 'analytics_panorama_user_id_idx');
66
        }
67
68
        return $schema;
69
    }
70
}