Completed
Push — master ( 79f16f...3ff314 )
by Morris
36:57 queued 16:20
created

Version14000Date20180626223656::changeSchema()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 38

Duplication

Lines 32
Ratio 84.21 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 3
dl 32
loc 38
rs 9.312
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (c) 2018 Arthur Schiwon <[email protected]>
5
 *
6
 * @author Arthur Schiwon <[email protected]>
7
 *
8
 * @license GNU AGPL version 3 or any later version
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Affero General Public License as
12
 * published by the Free Software Foundation, either version 3 of the
13
 * License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 *
23
 */
24
25
namespace OC\Core\Migrations;
26
27
use OCP\DB\ISchemaWrapper;
28
use OCP\Migration\SimpleMigrationStep;
29
30
class Version14000Date20180626223656 extends SimpleMigrationStep {
31
	public function changeSchema(\OCP\Migration\IOutput $output, \Closure $schemaClosure, array $options) {
32
		/** @var ISchemaWrapper $schema */
33
		$schema = $schemaClosure();
34 View Code Duplication
		if(!$schema->hasTable('whats_new')) {
35
			$table = $schema->createTable('whats_new');
36
			$table->addColumn('id', 'integer', [
37
				'autoincrement' => true,
38
				'notnull' => true,
39
				'length' => 4,
40
				'unsigned' => true,
41
			]);
42
			$table->addColumn('version', 'string', [
43
				'notnull' => true,
44
				'length' => 64,
45
				'default' => '11',
46
			]);
47
			$table->addColumn('etag', 'string', [
48
				'notnull' => true,
49
				'length' => 64,
50
				'default' => '',
51
			]);
52
			$table->addColumn('last_check', 'integer', [
53
				'notnull' => true,
54
				'length' => 4,
55
				'unsigned' => true,
56
				'default' => 0,
57
			]);
58
			$table->addColumn('data', 'text', [
59
				'notnull' => true,
60
				'default' => '',
61
			]);
62
			$table->setPrimaryKey(['id']);
63
			$table->addUniqueIndex(['version']);
64
			$table->addIndex(['version', 'etag'], 'version_etag_idx');
65
		}
66
67
		return $schema;
68
	}
69
}
70