Passed
Push — master ( 7ad038...6c6f41 )
by Morris
13:41 queued 10s
created

Version1010Date20200630191755   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A changeSchema() 0 17 2
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * @copyright Copyright (c) 2020 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
namespace OCA\FederatedFileSharing\Migration;
26
27
use Closure;
28
use Doctrine\DBAL\Types\Types;
29
use OCP\DB\ISchemaWrapper;
30
use OCP\Migration\IOutput;
31
use OCP\Migration\SimpleMigrationStep;
32
33
class Version1010Date20200630191755 extends SimpleMigrationStep {
34
	/**
35
	 * @param IOutput $output
36
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
37
	 * @param array $options
38
	 * @return null|ISchemaWrapper
39
	 */
40
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
41
		/** @var ISchemaWrapper $schema */
42
		$schema = $schemaClosure();
43
44
		if (!$schema->hasTable('federated_reshares')) {
45
			$table = $schema->createTable('federated_reshares');
46
			$table->addColumn('share_id', Types::INTEGER, [
47
				'notnull' => true,
48
				'length' => 4,
49
			]);
50
			$table->addColumn('remote_id', Types::INTEGER, [
51
				'notnull' => true,
52
				'length' => 4,
53
			]);
54
			$table->addUniqueIndex(['share_id'], 'share_id_index');
55
		}
56
		return $schema;
57
	}
58
}
59