Passed
Push — master ( f66003...c58f8d )
by Joas
14:36 queued 13s
created

Version24000Date20220131153041::changeSchema()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
nc 2
nop 3
dl 0
loc 13
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * @copyright Copyright (c) 2022 Joas Schilling <[email protected]>
6
 *
7
 * @author Joas Schilling <[email protected]>
8
 *
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
namespace OC\Core\Migrations;
27
28
use Closure;
29
use OCP\DB\ISchemaWrapper;
30
use OCP\DB\Types;
31
use OCP\Migration\IOutput;
32
use OCP\Migration\SimpleMigrationStep;
33
34
class Version24000Date20220131153041 extends SimpleMigrationStep {
35
	/**
36
	 * @param IOutput $output
37
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
38
	 * @param array $options
39
	 * @return null|ISchemaWrapper
40
	 */
41
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
42
		/** @var ISchemaWrapper $schema */
43
		$schema = $schemaClosure();
44
45
		$table = $schema->getTable('jobs');
46
		if (!$table->hasColumn('time_sensitive')) {
47
			$table->addColumn('time_sensitive', Types::SMALLINT, [
48
				'default' => 1,
49
			]);
50
			$table->addIndex(['time_sensitive'], 'jobs_time_sensitive');
51
			return $schema;
52
		}
53
		return null;
54
	}
55
}
56