Version20170808221437   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 25
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A changeSchema() 0 15 4
1
<?php
2
/**
3
 * Files_antivirus
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Viktar Dubiniuk <[email protected]>
9
 *
10
 * @copyright Viktar Dubiniuk 2018
11
 * @license AGPL-3.0
12
 */
13
14
namespace OCA\Files_Antivirus\Migrations;
15
16
use Doctrine\DBAL\Schema\Schema;
17
use Doctrine\DBAL\Types\Type;
18
use OCP\Migration\ISchemaMigration;
19
20
/**
21
 * Updates some fields to bigint if required
22
 */
23
class Version20170808221437 implements ISchemaMigration {
24
	/**
25
	 * @param Schema $schema
26
	 * @param array $options
27
	 *
28
	 * @return void
29
	 * @throws \Doctrine\DBAL\DBALException
30
	 * @throws \Doctrine\DBAL\Schema\SchemaException
31
	 */
32
	public function changeSchema(Schema $schema, array $options) {
33
		$prefix = $options['tablePrefix'];
34
35
		if ($schema->hasTable("${prefix}files_antivirus")) {
36
			$table = $schema->getTable("{$prefix}files_antivirus");
37
38
			$fileIdColumn = $table->getColumn('fileid');
39
			if ($fileIdColumn
40
				&& $fileIdColumn->getType()->getName() !== Type::BIGINT
41
			) {
42
				$fileIdColumn->setType(Type::getType(Type::BIGINT));
43
				$fileIdColumn->setOptions(['length' => 20]);
44
			}
45
		}
46
	}
47
}
48