Passed
Push — split-cluster-person ( 5b741f )
by Matias
05:21
created

Version000604Date20200908224225   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 39
ccs 0
cts 18
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A postSchemaChange() 0 6 1
A __construct() 0 2 1
A changeSchema() 0 11 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\IDBConnection;
10
use OCP\Migration\IOutput;
11
use OCP\Migration\SimpleMigrationStep;
12
13
/**
14
 * Auto-generated migration step: Please modify to your needs!
15
 */
16
class Version000604Date20200908224225 extends SimpleMigrationStep {
17
18
	/** @var IDBConnection */
19
	protected $connection;
20
21
	public function __construct(IDBConnection $connection) {
22
		$this->connection = $connection;
23
	}
24
25
	/**
26
	 * @param IOutput $output
27
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
28
	 * @param array $options
29
	 * @return null|ISchemaWrapper
30
	 */
31
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
32
		/** @var ISchemaWrapper $schema */
33
		$schema = $schemaClosure();
34
35
		$personsTable = $schema->getTable('facerecog_persons');
36
		$personsTable->changeColumn('name', [
37
			'notnull' => false,
38
			'default' => null,
39
		]);
40
41
		return $schema;
42
	}
43
44
	/**
45
	 * @param IOutput $output
46
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
47
	 * @param array $options
48
	 */
49
	public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
50
		$query = $this->connection->getQueryBuilder();
51
		$query->update('facerecog_persons')
52
			->set('name', $query->createNamedParameter(null))
53
			->where($query->expr()->iLike('name', 'New person %'));
54
		$query->execute();
55
	}
56
57
}
58