Passed
Push — master ( 465e91...f452e2 )
by Roeland
12:18 queued 10s
created

Version1011Date20190806104428::changeSchema()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 22
nc 1
nop 3
dl 0
loc 31
rs 9.568
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace OCA\DAV\Migration;
6
7
use Closure;
8
use Doctrine\DBAL\Types\Type;
9
use OCP\DB\ISchemaWrapper;
10
use OCP\Migration\SimpleMigrationStep;
11
use OCP\Migration\IOutput;
12
13
/**
14
 * Auto-generated migration step: Please modify to your needs!
15
 */
16
class Version1011Date20190806104428 extends SimpleMigrationStep {
17
	/**
18
	 * @param IOutput $output
19
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
20
	 * @param array $options
21
	 * @return null|ISchemaWrapper
22
	 */
23
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
24
		/** @var ISchemaWrapper $schema */
25
		$schema = $schemaClosure();
26
27
		$table = $schema->createTable('dav_cal_proxy');
28
		$table->addColumn('id', Type::BIGINT, [
29
			'autoincrement' => true,
30
			'notnull' => true,
31
			'length' => 11,
32
			'unsigned' => true,
33
		]);
34
		$table->addColumn('owner_id', Type::STRING, [
35
			'notnull' => true,
36
			'length' => 64,
37
		]);
38
		$table->addColumn('proxy_id', Type::STRING, [
39
			'notnull' => true,
40
			'length' => 64,
41
		]);
42
		$table->addColumn('permissions', Type::INTEGER, [
43
			'notnull' => false,
44
			'length' => 4,
45
			'unsigned' => true,
46
		]);
47
48
		$table->setPrimaryKey(['id']);
49
		$table->addUniqueIndex(['owner_id', 'proxy_id', 'permissions'], 'dav_cal_proxy_uidx');
50
		$table->addIndex(['owner_id'], 'dav_cal_proxy_ioid');
51
		$table->addIndex(['proxy_id'], 'dav_cal_proxy_ipid');
52
53
		return $schema;
54
	}
55
}
56