Completed
Push — master ( 25f782...8bd48c )
by Maxence
03:25
created

SetMemberTypeToDefault   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 45
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getName() 0 3 1
A run() 0 3 1
A setMemberTypeToDefault() 0 12 1
1
<?php
2
/**
3
 * Circles - Bring cloud-users closer together.
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Maxence Lange <[email protected]>
9
 * @copyright 2017
10
 * @license GNU AGPL version 3 or any later version
11
 *
12
 * This program is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Affero General Public License as
14
 * published by the Free Software Foundation, either version 3 of the
15
 * License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU Affero General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU Affero General Public License
23
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
 *
25
 */
26
27
namespace OCA\Circles\Migration;
28
29
use OCA\Circles\Db\CoreRequestBuilder;
30
use OCP\IConfig;
31
use OCP\IDBConnection;
32
use OCP\Migration\IOutput;
33
use OCP\Migration\IRepairStep;
34
35
/**
36
 * Class UsingShortenUniqueIdInsteadOfCircleId
37
 *
38
 * @package OCA\Circles\Migration
39
 */
40
class SetMemberTypeToDefault implements IRepairStep {
41
42
	/** @var IDBConnection */
43
	protected $connection;
44
45
	/** @var  IConfig */
46
	protected $config;
47
48
	public function __construct(IDBConnection $connection, IConfig $config) {
49
		$this->connection = $connection;
50
		$this->config = $config;
51
	}
52
53
	/**
54
	 * Returns the step's name
55
	 *
56
	 * @return string
57
	 * @since 9.1.0
58
	 */
59
	public function getName() {
60
		return 'Using shorten unique id instead of circle id';
61
	}
62
63
	/**
64
	 * @param IOutput $output
65
	 */
66
	public function run(IOutput $output) {
67
		$this->setMemberTypeToDefault();
68
	}
69
70
71
	private function setMemberTypeToDefault() {
72
73
		$qb = $this->connection->getQueryBuilder();
74
		$qb->update(CoreRequestBuilder::TABLE_MEMBERS)
75
		   ->where(
76
			   $qb->expr()
77
				  ->eq('type', $qb->createNamedParameter(0))
78
		   );
79
80
		$qb->set('type', $qb->createNamedParameter(1));
81
		$qb->execute();
82
	}
83
84
}
85
86
87