Passed
Push — find-similar ( e73d27...200d3c )
by Matias
04:37
created

Version000516Date20200420003814   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
dl 0
loc 53
ccs 0
cts 30
cp 0
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A preSchemaChange() 0 1 1
A changeSchema() 0 29 2
A postSchemaChange() 0 1 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace OCA\FaceRecognition\Migration;
6
7
use Closure;
8
use OCP\DB\ISchemaWrapper;
9
use OCP\Migration\SimpleMigrationStep;
10
use OCP\Migration\IOutput;
11
12
class Version000516Date20200420003814 extends SimpleMigrationStep {
13
14
	/**
15
	 * @param IOutput $output
16
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
17
	 * @param array $options
18
	 */
19
	public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
20
	}
21
22
	/**
23
	 * @param IOutput $output
24
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
25
	 * @param array $options
26
	 * @return null|ISchemaWrapper
27
	 */
28
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
29
		/** @var ISchemaWrapper $schema */
30
		$schema = $schemaClosure();
31
32
		if (!$schema->hasTable('facerecog_relations')) {
33
			$table = $schema->createTable('facerecog_relations');
34
			$table->addColumn('id', 'integer', [
35
				'autoincrement' => true,
36
				'notnull' => true,
37
				'unsigned' => true,
38
			]);
39
			$table->addColumn('face1', 'integer', [
40
				'notnull' => true,
41
				'length' => 4,
42
			]);
43
			$table->addColumn('face2', 'integer', [
44
				'notnull' => true,
45
				'length' => 4,
46
			]);
47
			$table->addColumn('state', 'integer', [
48
				'notnull' => true,
49
				'length' => 4,
50
			]);
51
52
			$table->setPrimaryKey(['id']);
53
			$table->addIndex(['face1'], 'relation_faces_1_idx');
54
			$table->addIndex(['face2'], 'relation_faces_2_idx');
55
		}
56
		return $schema;
57
	}
58
59
	/**
60
	 * @param IOutput $output
61
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
62
	 * @param array $options
63
	 */
64
	public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
65
	}
66
}
67