Passed
Push — master ( d70b01...159d75 )
by Morris
11:29
created

Version1008Date20181114084440   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A changeSchema() 0 16 4
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * @copyright Copyright (c) 2018, Joas Schilling <[email protected]>
6
 *
7
 * @author Joas Schilling <[email protected]>
8
 *
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
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
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
namespace OCA\DAV\Migration;
27
28
use Closure;
29
use OCP\DB\ISchemaWrapper;
30
use OCP\Migration\SimpleMigrationStep;
31
use OCP\Migration\IOutput;
32
33
class Version1008Date20181114084440 extends SimpleMigrationStep {
34
35
36
	/**
37
	 * @param IOutput $output
38
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
39
	 * @param array $options
40
	 * @return null|ISchemaWrapper
41
	 */
42
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
43
		/** @var ISchemaWrapper $schema */
44
		$schema = $schemaClosure();
45
46
		if ($schema->hasTable('calendarchanges')) {
47
			$calendarChangesTable = $schema->getTable('calendarchanges');
48
			if ($calendarChangesTable->hasIndex('calendarid_calendartype_synctoken')) {
49
				$calendarChangesTable->dropIndex('calendarid_calendartype_synctoken');
50
			}
51
52
			if (!$calendarChangesTable->hasIndex('calid_type_synctoken')) {
53
				$calendarChangesTable->addIndex(['calendarid', 'calendartype', 'synctoken'], 'calid_type_synctoken');
54
			}
55
		}
56
57
		return $schema;
58
	}
59
}
60