Completed
Push — stable10 ( 36ab92...0b967a )
by
unknown
22s
created

Version20170808221437::changeSchema()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.2
c 0
b 0
f 0
cc 4
eloc 8
nc 3
nop 2
1
<?php
2
3
namespace OCA\Files_Antivirus\Migrations;
4
5
use Doctrine\DBAL\Schema\Schema;
6
use Doctrine\DBAL\Types\Type;
7
use OCP\Migration\ISchemaMigration;
8
9
/** Updates some fields to bigint if required */
10
class Version20170808221437 implements ISchemaMigration {
11
	public function changeSchema(Schema $schema, array $options) {
12
		$prefix = $options['tablePrefix'];
13
14
		if ($schema->hasTable("${prefix}files_antivirus")) {
15
			$table = $schema->getTable("{$prefix}files_antivirus");
16
17
			$fileIdColumn = $table->getColumn('fileid');
18
			if ($fileIdColumn && $fileIdColumn->getType()->getName() !== Type::BIGINT) {
19
				$fileIdColumn->setType(Type::getType(Type::BIGINT));
20
				$fileIdColumn->setOptions(['length' => 20]);
21
			}
22
		}
23
	}
24
}
25