Completed
Push — master ( 9140bb...927ffd )
by Thomas
15:27
created

Version20170418154659   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A changeSchema() 0 12 3
1
<?php
2
/**
3
 * @author Vincent Petry <[email protected]>
4
 *
5
 * @copyright Copyright (c) 2017, ownCloud GmbH
6
 * @license AGPL-3.0
7
 *
8
 * This code is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License, version 3,
10
 * as published by the Free Software Foundation.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License, version 3,
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19
 *
20
 */
21
namespace OC\Migrations;
22
23
use Doctrine\DBAL\Schema\Schema;
24
use OCP\Migration\ISchemaMigration;
25
26
/**
27
 * Remove unique constraint on account table email column
28
 */
29
class Version20170418154659 implements ISchemaMigration {
30
31
	public function changeSchema(Schema $schema, array $options) {
32
		$prefix = $options['tablePrefix'];
33
		$table = $schema->getTable("{$prefix}accounts");
34
35
		// in beta versions a constraint was added, remove it if it exists
36
		foreach ($table->getIndexes() as $index) {
37
			if ($index->spansColumns(['email'])) {
38
				$table->dropIndex($index->getName());
39
				break;
40
			}
41
		}
42
	}
43
}
44