Version011602Date20230613160650   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
dl 0
loc 22
rs 10
c 1
b 0
f 1
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A changeSchema() 0 16 3
A __construct() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @copyright Copyright 2023, Julien Veyssier <[email protected]>
7
 *
8
 * @author Julien Veyssier <[email protected]>
9
 *
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
namespace OCA\OAuth2\Migration;
27
28
use Closure;
29
use OCP\DB\ISchemaWrapper;
30
use OCP\Migration\IOutput;
31
use OCP\Migration\SimpleMigrationStep;
32
33
class Version011602Date20230613160650 extends SimpleMigrationStep {
34
35
	public function __construct(
36
	) {
37
	}
38
39
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
40
		/** @var ISchemaWrapper $schema */
41
		$schema = $schemaClosure();
42
43
		if ($schema->hasTable('oauth2_clients')) {
44
			$table = $schema->getTable('oauth2_clients');
45
			if ($table->hasColumn('secret')) {
46
				$column = $table->getColumn('secret');
47
				// we still change the column length in case Version011601Date20230522143227
48
				// has run before it was changed to set the length to 512
49
				$column->setLength(512);
50
				return $schema;
51
			}
52
		}
53
54
		return null;
55
	}
56
}
57