aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib/Migration/Version1020Date20240403003535.php
blob: 3e85edf40b6fc39425b20d50e320f9b375b1db08 (plain)
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
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace OCA\Files_Trashbin\Migration;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\Attributes\AddColumn;
use OCP\Migration\Attributes\ColumnType;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

#[AddColumn(table: 'files_trash', name: 'deleted_by', type: ColumnType::STRING)]
class Version1020Date20240403003535 extends SimpleMigrationStep {

	/**
	 * @param Closure(): ISchemaWrapper $schemaClosure
	 */
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
		/** @var ISchemaWrapper $schema */
		$schema = $schemaClosure();

		if (!$schema->hasTable('files_trash')) {
			return null;
		}

		$table = $schema->getTable('files_trash');
		$table->addColumn('deleted_by', Types::STRING, [
			'notnull' => false,
			'length' => 64,
		]);

		return $schema;
	}
}