Completed
Push — master ( 684518...9a4927 )
by Tom
45s
created

Version20170605143658::changeSchema()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 2
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace OC\Migrations;
3
4
use Doctrine\DBAL\Schema\Schema;
5
use OCP\Migration\ISchemaMigration;
6
7
/**
8
 * Updates the column lengths for the migrations table to reflect changes in its schema
9
 */
10
class Version20170605143658 implements ISchemaMigration {
11
12
	public function changeSchema(Schema $schema, array $options) {
13
		// Get the table
14
		$prefix = $options['tablePrefix'];
15
		$table = $schema->getTable("{$prefix}migrations");
16
17
		// Check column length to see if migration is necessary necessary
18
		if($table->getColumn('app')->getLength() === 177) {
19
			// then this server was installed after the fix
20
			return;
21
		}
22
23
		// Need to shorten columns
24
		$table->getColumn('app')->setLength(177);
25
		$table->getColumn('version')->setLength(14);
26
	}
27
}
28