Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Version1040Date20200422130220.php « Migration « lib - github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 17377e460292bee65a89a621bac3716553b629f0 (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
44
45
46
47
48
49
50
51
52
53
54
55
<?php

declare(strict_types=1);

namespace OCA\Mail\Migration;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version1040Date20200422130220 extends SimpleMigrationStep {

	/** @var IDBConnection */
	protected $connection;

	public function __construct(IDBConnection $connection) {
		$this->connection = $connection;
	}

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

		$schema->dropTable('mail_messages');

		return $schema;
	}

	public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
		// Reset locks and sync tokens
		$qb1 = $this->connection->getQueryBuilder();
		$updateMailboxes = $qb1->update('mail_mailboxes')
			->set('sync_new_lock', $qb1->createNamedParameter(null))
			->set('sync_new_token', $qb1->createNamedParameter(null))
			->set('sync_changed_lock', $qb1->createNamedParameter(null))
			->set('sync_changed_token', $qb1->createNamedParameter(null))
			->set('sync_vanished_lock', $qb1->createNamedParameter(null))
			->set('sync_vanished_token', $qb1->createNamedParameter(null));
		$updateMailboxes->execute();

		// Clean up some orphaned data
		$qb2 = $this->connection->getQueryBuilder();
		$deleteRecipients = $qb2->delete('mail_recipients');
		$deleteRecipients->execute();
	}
}