aboutsummaryrefslogtreecommitdiffstats
path: root/core/Migrations/Version24000Date20211210141942.php
blob: 50b1d89557e3d472fc18089de53fc0714357a1f0 (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
43
<?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\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

/**
 * Email addresses are case insensitive
 * But previously a user could enter any casing of the email address
 * and we would in case of a login lower case the input and the database value.
 *
 */
class Version24000Date20211210141942 extends SimpleMigrationStep {
	public function __construct(
		protected IDBConnection $connection,
	) {
	}

	/**
	 * @param IOutput $output
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
	 * @param array $options
	 */
	public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
		$update = $this->connection->getQueryBuilder();

		$update->update('preferences')
			->set('configvalue', $update->func()->lower('configvalue'))
			->where($update->expr()->eq('appid', $update->createNamedParameter('settings')))
			->andWhere($update->expr()->eq('configkey', $update->createNamedParameter('email')));

		$update->executeStatement();
	}
}