Completed
Push — master ( 79bb29...554f60 )
by Thomas
21:08
created

Version20171215103657::changeSchema()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 3
nop 2
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @author Tom Needham <[email protected]>
5
 *
6
 * @copyright Copyright (c) 2017, ownCloud GmbH.
7
 * @license AGPL-3.0
8
 *
9
 * This code is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License, version 3,
11
 * as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License, version 3,
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
20
 *
21
 */
22
23
namespace OCA\Files_Sharing\Migrations;
24
25
use Doctrine\DBAL\Schema\Schema;
26
use OCP\Migration\ISchemaMigration;
27
28
/**
29
 * Another index to optimise share loading
30
 */
31
class Version20171215103657 implements ISchemaMigration {
32
33
	public function changeSchema(Schema $schema, array $options) {
34
		$indexName = 'item_source_type_index';
35
		$columns = ['item_source', 'share_type', 'item_type'];
36
37
		$prefix = $options['tablePrefix'];
38
39
		if ($schema->hasTable("${prefix}share")) {
40
			$table = $schema->getTable("${prefix}share");
41
			if (!$table->hasIndex($indexName)) {
42
				$table->addIndex($columns, $indexName);
43
			}
44
		}
45
    }
46
}