Version2102Date20200712203332   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A preSchemaChange() 0 1 1
A changeSchema() 0 37 2
A postSchemaChange() 0 1 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace OCA\audioplayer\Migration;
6
7
use Closure;
8
use OCP\DB\ISchemaWrapper;
9
use OCP\Migration\IOutput;
10
use OCP\Migration\SimpleMigrationStep;
11
12
/**
13
 * Auto-generated migration step: Please modify to your needs!
14
 */
15
class Version2102Date20200712203332 extends SimpleMigrationStep {
16
17
    /**
18
     * @param IOutput $output
19
     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
20
     * @param array $options
21
     */
22
    public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
23
    }
24
25
    /**
26
     * @param IOutput $output
27
     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
28
     * @param array $options
29
     * @return null|ISchemaWrapper
30
     */
31
    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
32
        /** @var ISchemaWrapper $schema */
33
        $schema = $schemaClosure();
34
35
        if (!$schema->hasTable('audioplayer_whats_new')) {
36
            $table = $schema->createTable('audioplayer_whats_new');
37
            $table->addColumn('id', 'integer', [
38
                'autoincrement' => true,
39
                'notnull' => true,
40
                'length' => 4,
41
                'unsigned' => true,
42
            ]);
43
            $table->addColumn('version', 'string', [
44
                'notnull' => true,
45
                'length' => 64,
46
                'default' => '11',
47
            ]);
48
            $table->addColumn('etag', 'string', [
49
                'notnull' => true,
50
                'length' => 64,
51
                'default' => '',
52
            ]);
53
            $table->addColumn('last_check', 'integer', [
54
                'notnull' => true,
55
                'length' => 4,
56
                'unsigned' => true,
57
                'default' => 0,
58
            ]);
59
            $table->addColumn('data', 'text', [
60
                'notnull' => true,
61
                'default' => '',
62
            ]);
63
            $table->setPrimaryKey(['id']);
64
            $table->addUniqueIndex(['version'], 'audioplayer_whats_new_v_idx');
65
            $table->addIndex(['version', 'etag'], 'audioplayer_whats_new_v_e_idx');
66
        }
67
        return $schema;
68
    }
69
70
    /**
71
     * @param IOutput $output
72
     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
73
     * @param array $options
74
     */
75
    public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
76
    }
77
}