Completed
Pull Request — master (#546)
by Thomas
06:53
created

Version20161122092159   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 35
ccs 0
cts 26
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 19 2
A down() 0 7 1
1
<?php
2
3
namespace OCA\activity\Migrations;
4
5
use Doctrine\DBAL\Migrations\AbstractMigration;
6
use Doctrine\DBAL\Platforms\OraclePlatform;
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\DBAL\Types\Type;
9
10
class Version20161122092159 extends AbstractMigration {
11
    /**
12
     * @param Schema $schema
13
     */
14
    public function up(Schema $schema) {
15
		$prefix = $this->connection->getPrefix();
16
		$tableName = "{$prefix}activity";
17
		if ($this->connection->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...
18
			$tableName = $this->connection->quoteIdentifier($tableName);
19
			$this->addSql("ALTER TABLE $tableName ADD (\"tmpsubjectparams\" CLOB, \"tmpmessageparams\" CLOB)");
20
			$this->addSql("UPDATE $tableName SET \"tmpsubjectparams\"=\"subjectparams\", \"tmpmessageparams\"=\"messageparams\"");
21
			$this->addSql("COMMIT");
22
			$this->addSql("ALTER TABLE $tableName DROP COLUMN \"subjectparams\"");
23
			$this->addSql("ALTER TABLE $tableName DROP COLUMN \"messageparams\"");
24
			$this->addSql("ALTER TABLE $tableName RENAME COLUMN \"tmpsubjectparams\" TO \"subjectparams\"");
25
			$this->addSql("ALTER TABLE $tableName RENAME COLUMN \"tmpmessageparams\" TO \"messageparams\"");
26
		} else {
27
			$table = $schema->getTable($tableName);
28
			$table->changeColumn('app', ['length' => 32]);
29
			$table->changeColumn('subjectparams', ['type' => Type::getType('text')]);
30
			$table->changeColumn('messageparams', ['type' => Type::getType('text')]);
31
		}
32
    }
33
34
    /**
35
     * @param Schema $schema
36
     */
37
    public function down(Schema $schema) {
38
		$prefix = $this->connection->getPrefix();
39
		$table = $schema->getTable("{$prefix}activity");
40
		$table->changeColumn('app', ['length' => 255]);
41
		$table->changeColumn('subjectparams', ['type' => Type::getType('string'), 'length' => '4000']);
42
		$table->changeColumn('messageparams', ['type' => Type::getType('string'), 'length' => '4000']);
43
    }
44
}
45