Passed
Push — master ( 5df640...0c0e41 )
by Roeland
10:30 queued 10s
created

Version16000Date20190212081545::changeSchema()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 60
Code Lines 45

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 45
nc 1
nop 3
dl 0
loc 60
rs 9.2
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
declare(strict_types=1);
3
/**
4
 * @copyright Copyright (c) 2018 Roeland Jago Douma <[email protected]>
5
 *
6
 * @author Roeland Jago Douma <[email protected]>
7
 *
8
 * @license GNU AGPL version 3 or any later version
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Affero General Public License as
12
 * published by the Free Software Foundation, either version 3 of the
13
 * License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 *
23
 */
24
25
namespace OC\Core\Migrations;
26
27
use Closure;
28
use Doctrine\DBAL\Types\Type;
29
use OCP\DB\ISchemaWrapper;
30
use OCP\Migration\SimpleMigrationStep;
31
use OCP\Migration\IOutput;
32
33
class Version16000Date20190212081545 extends SimpleMigrationStep {
34
	/**
35
	 * @param IOutput $output
36
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
37
	 * @param array $options
38
	 * @return null|ISchemaWrapper
39
	 */
40
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
41
		/** @var ISchemaWrapper $schema */
42
		$schema = $schemaClosure();
43
44
		$table = $schema->createTable('login_flow_v2');
45
		$table->addColumn('id', Type::BIGINT, [
46
			'autoincrement' => true,
47
			'notnull' => true,
48
			'length' => 20,
49
			'unsigned' => true,
50
		]);
51
		$table->addColumn('timestamp', Type::BIGINT, [
52
			'notnull' => true,
53
			'length' => 20,
54
			'unsigned' => true,
55
		]);
56
		$table->addColumn('started', Type::SMALLINT, [
57
			'notnull' => true,
58
			'length' => 1,
59
			'unsigned' => true,
60
			'default' => 0,
61
		]);
62
		$table->addColumn('poll_token', Type::STRING, [
63
			'notnull' => true,
64
			'length' => 255,
65
		]);
66
		$table->addColumn('login_token', Type::STRING, [
67
			'notnull' => true,
68
			'length' => 255,
69
		]);
70
		$table->addColumn('public_key', Type::TEXT, [
71
			'notnull' => true,
72
			'length' => 32768,
73
		]);
74
		$table->addColumn('private_key', Type::TEXT, [
75
			'notnull' => true,
76
			'length' => 32768,
77
		]);
78
		$table->addColumn('client_name', Type::STRING, [
79
			'notnull' => true,
80
			'length' => 255,
81
		]);
82
		$table->addColumn('login_name', Type::STRING, [
83
			'notnull' => false,
84
			'length' => 255,
85
		]);
86
		$table->addColumn('server', Type::STRING, [
87
			'notnull' => false,
88
			'length' => 255,
89
		]);
90
		$table->addColumn('app_password', Type::STRING, [
91
			'notnull' => false,
92
			'length' => 1024,
93
		]);
94
		$table->setPrimaryKey(['id']);
95
		$table->addUniqueIndex(['poll_token']);
96
		$table->addUniqueIndex(['login_token']);
97
		$table->addIndex(['timestamp']);
98
99
		return $schema;
100
	}
101
}
102