aboutsummaryrefslogtreecommitdiffstats
path: root/core/Migrations/Version23000Date20211203110726.php
blob: c91645ddeb3a6aba8f4f8a96b31578b8a65bebfa (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
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2021 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\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version23000Date20211203110726 extends SimpleMigrationStep {
	private const TABLE_NAME = 'profile_config';

	/**
	 * @param IOutput $output
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
	 * @param array $options
	 * @return null|ISchemaWrapper
	 */
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
		/** @var ISchemaWrapper $schema */
		$schema = $schemaClosure();

		$table = $schema->getTable(self::TABLE_NAME);
		if ($table->hasIndex('user_id')) {
			$table->renameIndex('user_id', self::TABLE_NAME . '_user_id_idx');
			return $schema;
		}
		return null;
	}
}