Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/Migration/Version0161Date20190902103701.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,14 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
'default' => true,
]);
$mailboxTable->setPrimaryKey(['id']);
// We allow each mailbox name just once
$mailboxTable->addUniqueIndex([
'account_id',
'name',
]);
/*
* We allow each mailbox name just once
* @see \OCA\Mail\Migration\Version3500Date20231115184458::changeSchema
*/
// $mailboxTable->addUniqueIndex([
// 'account_id',
// 'name',
// ]);

return $schema;
}
Expand Down
15 changes: 12 additions & 3 deletions lib/Migration/Version3500Date20231115184458.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,20 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt

$mailboxesTable = $schema->getTable('mail_mailboxes');

$indexOld = 'UNIQ_22DEBD839B6B5FBA5E237E06';
$indexNew = 'mail_mb_account_id_name_hash';

if ($mailboxesTable->hasIndex($indexOld)) {
$mailboxesTable->dropIndex($indexOld);
/**
* Variant 1 - with table prefix
*/
if ($mailboxesTable->hasIndex('UNIQ_22DEBD839B6B5FBA5E237E06')) {
$mailboxesTable->dropIndex('UNIQ_22DEBD839B6B5FBA5E237E06');
}
/**
* Variant 2 - without table prefix
* @see \OCA\Mail\Migration\Version5006Date20250927130132::changeSchema
*/
if ($mailboxesTable->hasIndex('UNIQ_45754FF89B6B5FBA5E237E06')) {
$mailboxesTable->dropIndex('UNIQ_45754FF89B6B5FBA5E237E06');
}

if (!$mailboxesTable->hasIndex($indexNew)) {
Expand Down
11 changes: 11 additions & 0 deletions lib/Migration/Version5006Date20250927130132.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$schema = $schemaClosure();

$mailboxes = $schema->getTable('mail_mailboxes');

/**
* Make sure the old account_id+name index is gone. The DB won't allow
* the name length increase otherwise
*
* @see \OCA\Mail\Migration\Version3500Date20231115184458::changeSchema
*/
if ($mailboxes->hasIndex('UNIQ_45754FF89B6B5FBA5E237E06')) {
$mailboxes->dropIndex('UNIQ_45754FF89B6B5FBA5E237E06');
}

$mailboxes->modifyColumn(
'name',
['length' => 1024]
Expand Down
46 changes: 46 additions & 0 deletions lib/Migration/Version5006Date20251015082003.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

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

namespace OCA\Mail\Migration;

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

class Version5006Date20251015082003 extends SimpleMigrationStep {

/**
* @param IOutput $output
* @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options
* @return null|ISchemaWrapper
*/
#[Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
$schema = $schemaClosure();

/**
* Make sure the old account_id+name index is gone for good
*
* @see \OCA\Mail\Migration\Version3500Date20231115184458::changeSchema
*/
$mailboxesTable = $schema->getTable('mail_mailboxes');
if (!$mailboxesTable->hasIndex('UNIQ_45754FF89B6B5FBA5E237E06')) {
// Nothing to do
return null;
}

$mailboxesTable->dropIndex('UNIQ_45754FF89B6B5FBA5E237E06');

return $schema;
}

}