Completed
Pull Request — master (#546)
by Thomas
03:39
created

Version20161122092159::changeSchema()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 0
cts 14
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 11
nc 3
nop 2
crap 12
1
<?php
2
3
namespace OCA\activity\Migrations;
4
5
use Doctrine\DBAL\Platforms\OraclePlatform;
6
use Doctrine\DBAL\Schema\Schema;
7
use Doctrine\DBAL\Types\Type;
8
use OCP\Migration\ISchemaMigration;
9
10
class Version20161122092159 implements ISchemaMigration {
11
12
	/**
13
	 * @param Schema $schema
14
	 * @param array $options
15
	 */
16
	public function changeSchema(Schema $schema, array $options) {
17
		$prefix = $options['tablePrefix'];
18
		$tableName = "{$prefix}activity";
19
		$table = $schema->getTable($tableName);
20
		// we only apply this step if the columns is not yet a CLOB
21
		if ($table->getColumn('subjectparams')->getType() === Type::getType(Type::TEXT)) {
22
			return;
23
		}
24
25
		if (\OC::$server->getDatabaseConnection()->getDatabasePlatform() instanceof OraclePlatform) {
0 ignored issues
show
Bug introduced by
The class Doctrine\DBAL\Platforms\OraclePlatform does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
26
			return;
27
		}
28
		$table = $schema->getTable($tableName);
29
		$table->changeColumn('subjectparams', ['type' => Type::getType('text')]);
30
		$table->changeColumn('messageparams', ['type' => Type::getType('text')]);
31
    }
32
}
33