Completed
Push — master ( 721837...277496 )
by Victor
13:18
created

Version20170804201125::changeSchema()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 62
Code Lines 43

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 43
nc 2
nop 2
dl 0
loc 62
rs 9.4743
c 0
b 0
f 0

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_Trashbin\Migrations;
4
use Doctrine\DBAL\Schema\Schema;
5
use OCP\Migration\ISchemaMigration;
6
7
/** Creates initial schema */
8
class Version20170804201125 implements ISchemaMigration {
9
	public function changeSchema(Schema $schema, array $options) {
10
		$prefix = $options['tablePrefix'];
11
		if (!$schema->hasTable("{$prefix}files_trash")) {
12
			$table = $schema->createTable("{$prefix}files_trash");
13
			$table->addColumn('auto_id', 'bigint', [
14
				'autoincrement' => true,
15
				'unsigned' => false,
16
				'notnull' => true,
17
				'length' => 11,
18
			]);
19
20
			$table->addColumn('id', 'string', [
21
				'length' => 250,
22
				'notnull' => true,
23
				'default' => ''
24
			]);
25
26
			$table->addColumn('user', 'string', [
27
				'length' => 64,
28
				'notnull' => true,
29
				'default' => ''
30
			]);
31
32
			$table->addColumn('timestamp', 'string', [
33
				'length' => 12,
34
				'notnull' => true,
35
				'default' => ''
36
			]);
37
38
			$table->addColumn('location', 'string', [
39
				'length' => 512,
40
				'notnull' => true,
41
				'default' => ''
42
			]);
43
44
			$table->addColumn('type', 'string', [
45
				'length' => 4,
46
				'notnull' => false,
47
				'default' => null
48
			]);
49
50
			$table->addColumn('mime', 'string', [
51
				'length' => 255,
52
				'notnull' => false,
53
				'default' => null
54
			]);
55
56
			$table->setPrimaryKey(['auto_id']);
57
			$table->addIndex(
58
				['id'],
59
				'id_index'
60
			);
61
			$table->addIndex(
62
				['timestamp'],
63
				'timestamp_index'
64
			);
65
			$table->addIndex(
66
				['user'],
67
				'user_index'
68
			);
69
		}
70
	}
71
}
72