Passed
Push — master ( 3c693d...ccd5ca )
by Roeland
28:56 queued 14:09
created

Version21000Date20201120141228   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 31
c 5
b 0
f 0
dl 0
loc 52
rs 10
wmc 9

1 Method

Rating   Name   Duplication   Size   Complexity  
B changeSchema() 0 51 9
1
<?php
2
3
declare(strict_types=1);
4
5
namespace OC\Core\Migrations;
6
7
use Closure;
8
use OCP\DB\ISchemaWrapper;
9
use OCP\Migration\IOutput;
10
use OCP\Migration\SimpleMigrationStep;
11
12
class Version21000Date20201120141228 extends SimpleMigrationStep {
13
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
14
		/** @var ISchemaWrapper $schema */
15
		$schema = $schemaClosure();
16
17
		if ($schema->hasTable('authtoken')) {
18
			$table = $schema->getTable('authtoken');
19
			$loginNameColumn = $table->getColumn('login_name');
20
			if ($loginNameColumn->getLength() !== 255) {
21
				$loginNameColumn->setLength(255);
22
			}
23
			$table->changeColumn('type', [
24
				'notnull' => false,
25
			]);
26
			$table->changeColumn('remember', [
27
				'notnull' => false,
28
			]);
29
			$table->changeColumn('last_activity', [
30
				'notnull' => false,
31
			]);
32
			$table->changeColumn('last_check', [
33
				'notnull' => false,
34
			]);
35
		}
36
37
		if ($schema->hasTable('dav_job_status')) {
38
			$schema->dropTable('dav_job_status');
39
		}
40
41
		if ($schema->hasTable('systemtag')) {
42
			$table = $schema->getTable('systemtag');
43
			if ($table->hasColumn('systemtag')) {
44
				$table->dropColumn('assignable');
45
			}
46
		}
47
48
		if ($schema->hasTable('share')) {
49
			$table = $schema->getTable('share');
50
			if ($table->hasColumn('attributes')) {
51
				$table->dropColumn('attributes');
52
			}
53
		}
54
55
		if ($schema->hasTable('jobs')) {
56
			$table = $schema->getTable('jobs');
57
			$table->changeColumn('execution_duration', [
58
				'notnull' => false,
59
				'default' => 0,
60
			]);
61
		}
62
63
		return $schema;
64
	}
65
}
66