Completed
Push — stable10 ( 36ab92...0b967a )
by
unknown
22s
created

Version20170808220321::changeSchema()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 66
Code Lines 46

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 66
rs 9.3191
c 0
b 0
f 0
cc 3
eloc 46
nc 4
nop 2

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace OCA\Files_Antivirus\Migrations;
4
use Doctrine\DBAL\Schema\Schema;
5
use OCP\Migration\ISchemaMigration;
6
7
/** Creates initial schema */
8
class Version20170808220321 implements ISchemaMigration {
9
	public function changeSchema(Schema $schema, array $options) {
10
		$prefix = $options['tablePrefix'];
11
		if (!$schema->hasTable("{$prefix}files_antivirus")) {
12
			$table = $schema->createTable("{$prefix}files_antivirus");
13
			$table->addColumn('fileid', 'bigint', [
14
				'unsigned' => true,
15
				'notnull' => true,
16
				'length' => 11,
17
			]);
18
19
			$table->addColumn('check_time', 'integer', [
20
				'notnull' => true,
21
				'unsigned' => true,
22
				'default' => 0,
23
			]);
24
			$table->setPrimaryKey(['fileid']);
25
		}
26
27
		if (!$schema->hasTable("{$prefix}files_avir_status")) {
28
			$table = $schema->createTable("{$prefix}files_avir_status");
29
			$table->addColumn('id', 'integer', [
30
				'autoincrement' => true,
31
				'unsigned' => true,
32
				'notnull' => true,
33
				'length' => 11,
34
			]);
35
36
			$table->addColumn('group_id', 'integer', [
37
				'notnull' => true,
38
				'unsigned' => true,
39
				'default' => 0,
40
			]);
41
42
			$table->addColumn('status_type', 'integer', [
43
				'notnull' => true,
44
				'unsigned' => true,
45
				'default' => 0,
46
			]);
47
48
			$table->addColumn('result', 'integer', [
49
				'notnull' => true,
50
				'unsigned' => false,
51
				'default' => 0,
52
			]);
53
54
			$table->addColumn('match', 'string', [
55
				'length' => 64,
56
				'notnull' => false,
57
				'default' => null,
58
			]);
59
60
			$table->addColumn('description', 'string', [
61
				'length' => 64,
62
				'notnull' => false,
63
				'default' => null,
64
			]);
65
66
			$table->addColumn('status', 'integer', [
67
				'length' => 4,
68
				'notnull' => true,
69
				'default' => 0,
70
				'unsigned' => false,
71
			]);
72
			$table->setPrimaryKey(['id']);
73
		}
74
	}
75
}
76