Completed
Pull Request — master (#583)
by Tom
326:15 queued 324:43
created

Version20170718101647::changeSchema()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 3
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 2
crap 12
1
<?php
2
namespace OCA\activity\Migrations;
3
4
use Doctrine\DBAL\Schema\Schema;
5
use Doctrine\DBAL\Types\Type;
6
use OCP\Migration\ISchemaMigration;
7
8
/**
9
 * Moves activity id to bigint
10
 */
11
class Version20170718101647 implements ISchemaMigration {
12
13
	public function changeSchema(Schema $schema, array $options) {
14
		$prefix = $options['tablePrefix'];
15
		if ($schema->hasTable("${prefix}activity")) {
16
			$table = $schema->getTable("{$prefix}activity");
17
			$idColumn = $table->getColumn('activity_id');
18
			if ($idColumn){
19
				$idColumn->setType(Type::getType(Type::BIGINT));
20
				$idColumn->setOptions(['length' => 20]);
21
			}
22
23
		}
24
    }
25
}
26