Version20170724182159::changeSchema()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 23

Duplication

Lines 12
Ratio 52.17 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 12
loc 23
ccs 0
cts 20
cp 0
rs 9.552
c 0
b 0
f 0
cc 4
nc 8
nop 2
crap 20
1
<?php
2
3
namespace OCA\activity\Migrations;
4
5
use Doctrine\DBAL\Schema\Schema;
6
use Doctrine\DBAL\Types\Type;
7
use OCP\Migration\ISchemaMigration;
8
9
/**
10
 * Updates column type from integer to bigint
11
 */
12
13
class Version20170724182159 implements ISchemaMigration {
14
15
	/**
16
	 * @param Schema $schema
17
	 * @param array $options
18
	 */
19
	public function changeSchema(Schema $schema, array $options) {
20
		$prefix = $options['tablePrefix'];
21
		
22
		$activityTable = $schema->getTable("{$prefix}activity");
23
		$activityIdColumn = $activityTable->getColumn('activity_id');
24 View Code Duplication
		if ($activityIdColumn->getType()->getName() !== Type::BIGINT) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
			$activityIdColumn->setType(Type::getType(Type::BIGINT));
26
			$activityIdColumn->setOptions(['length' => 20]);
27
		}
28
		
29
		$objectIdColumn = $activityTable->getColumn('object_id');
30 View Code Duplication
		if ($objectIdColumn->getType()->getName() !== Type::BIGINT) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
			$objectIdColumn->setType(Type::getType(Type::BIGINT));
32
			$objectIdColumn->setOptions(['length' => 20]);
33
		}
34
		
35
		$activityMqTable = $schema->getTable("{$prefix}activity_mq");
36
		$mailIdColumn = $activityMqTable->getColumn('mail_id');
37 View Code Duplication
		if ($mailIdColumn->getType()->getName() !== Type::BIGINT) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
			$mailIdColumn->setType(Type::getType(Type::BIGINT));
39
			$mailIdColumn->setOptions(['length' => 20]);
40
		}
41
	}
42
}
43