Passed
Push — master ( 3eb748...99ee00 )
by Roeland
12:40 queued 12s
created

Version0002Date20200902144824::changeSchema()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 5
nc 1
nop 3
dl 0
loc 10
rs 10
c 1
b 0
f 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @copyright Copyright (c) 2020, Georg Ehrke
7
 *
8
 * @author Georg Ehrke <[email protected]>
9
 *
10
 * @license AGPL-3.0
11
 *
12
 * This code is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Affero General Public License, version 3,
14
 * as published by the Free Software Foundation.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License, version 3,
22
 * along with this program. If not, see <http://www.gnu.org/licenses/>
23
 *
24
 */
25
26
namespace OCA\UserStatus\Migration;
27
28
use OCP\DB\ISchemaWrapper;
29
use OCP\Migration\IOutput;
30
use OCP\Migration\SimpleMigrationStep;
31
32
/**
33
 * Class Version0001Date20200602134824
34
 *
35
 * @package OCA\UserStatus\Migration
36
 */
37
class Version0002Date20200902144824 extends SimpleMigrationStep {
38
39
	/**
40
	 * @param IOutput $output
41
	 * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
42
	 * @param array $options
43
	 * @return null|ISchemaWrapper
44
	 * @since 20.0.0
45
	 */
46
	public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
47
		/** @var ISchemaWrapper $schema */
48
		$schema = $schemaClosure();
49
50
		$statusTable = $schema->getTable('user_status');
51
52
		$statusTable->addIndex(['status_timestamp'], 'user_status_tstmp_ix');
53
		$statusTable->addIndex(['is_user_defined', 'status'], 'user_status_iud_ix');
54
55
		return $schema;
56
	}
57
}
58