Version0910Date20221109096049::preSchemaChange()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 1
ccs 0
cts 1
cp 0
crap 2
rs 10
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\IOutput;
10
use OCP\Migration\SimpleMigrationStep;
11
12
use OCP\IDBConnection;
13
14
class Version0910Date20221109096049 extends SimpleMigrationStep {
15
16
	private $connection;
17
18
	public function __construct(IDBConnection $connection) {
19
		$this->connection = $connection;
20
	}
21
22
	/**
23
	 * @param IOutput $output
24
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
25
	 * @param array $options
26
	 */
27
	public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
28
	}
29
30
	/**
31
	 * @param IOutput $output
32
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
33
	 * @param array $options
34
	 * @return null|ISchemaWrapper
35
	 */
36
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
37
		$schema = $schemaClosure();
38
39
		$table = $schema->getTable('facerecog_faces');
40
		if ($table->hasColumn('width') && $table->hasColumn('left')) {
41
			$table->dropColumn('left');
42
			$table->dropColumn('top');
43
			$table->dropColumn('right');
44
			$table->dropColumn('bottom');
45
		}
46
		return $schema;
47
	}
48
49
	/**
50
	 * @param IOutput $output
51
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
52
	 * @param array $options
53
	 */
54
	public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
55
	}
56
57
}
58