-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Expand file tree
/
Copy pathVersion34000Date20260521110333.php
More file actions
56 lines (48 loc) · 1.88 KB
/
Copy pathVersion34000Date20260521110333.php
File metadata and controls
56 lines (48 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Core\Migrations;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\Attributes\AddIndex;
use OCP\Migration\Attributes\CreateTable;
use OCP\Migration\Attributes\IndexType;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use Override;
#[CreateTable(
table: 'job_runs',
columns: ['class_id', 'pid', 'status', 'duration', 'ram_peak_usage'],
description: 'New table to store executions of background jobs',
)]
#[AddIndex(table: 'job_runs', type: IndexType::PRIMARY)]
#[AddIndex(table: 'job_runs', type: IndexType::INDEX, description: 'Allows to search on job status')]
class Version34000Date20260521110333 extends SimpleMigrationStep {
#[Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('job_runs')) {
$table = $schema->createTable('job_runs');
$table->addColumn('run_id', Types::BIGINT, [
'notnull' => true,
'unsigned' => true,
]);
$table->addColumn('class_id', Types::BIGINT, ['notnull' => true]);
$table->addColumn('pid', Types::INTEGER, ['notnull' => true]); // Should be MEDIUMINT
$table->addColumn('status', Types::SMALLINT, ['notnull' => true]); // Should be TINYINT
$table->addColumn('duration', Types::INTEGER, ['notnull' => true, 'default' => 0]);
$table->addColumn('ram_peak_usage', Types::INTEGER, ['notnull' => true, 'default' => 0]); // Should be MEDIUMINT
$table->setPrimaryKey(['run_id']);
$table->addIndex(['status'], 'status');
// Makes sure there is no auto-increment in Oracle
$schema->dropAutoincrementColumn('job_runs', 'run_id');
return $schema;
}
return null;
}
}