Merge pull request #3755 from nextcloud/backport/3745/stable23
[stable23] Add missing indices
This commit is contained in:
99
lib/Migration/Version10800Date20220422061816.php
Normal file
99
lib/Migration/Version10800Date20220422061816.php
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (c) 2022 Your name <your@email.com>
|
||||||
|
*
|
||||||
|
* @author Your name <your@email.com>
|
||||||
|
*
|
||||||
|
* @license GNU AGPL version 3 or any later version
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OCA\Deck\Migration;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Doctrine\DBAL\Schema\SchemaException;
|
||||||
|
use OCP\DB\ISchemaWrapper;
|
||||||
|
use OCP\Migration\IOutput;
|
||||||
|
use OCP\Migration\SimpleMigrationStep;
|
||||||
|
|
||||||
|
class Version10800Date20220422061816 extends SimpleMigrationStep {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param IOutput $output
|
||||||
|
* @param Closure(): ISchemaWrapper $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||||
|
* @param array $options
|
||||||
|
* @return null|ISchemaWrapper
|
||||||
|
* @throws SchemaException
|
||||||
|
*/
|
||||||
|
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||||
|
$schema = $schemaClosure();
|
||||||
|
|
||||||
|
$indexAdded = $this->addIndex($schema,
|
||||||
|
'deck_boards',
|
||||||
|
'idx_owner_modified',
|
||||||
|
[ 'owner', 'last_modified' ]
|
||||||
|
);
|
||||||
|
|
||||||
|
$indexAdded = $this->addIndex($schema,
|
||||||
|
'deck_board_acl',
|
||||||
|
'idx_participant_type',
|
||||||
|
[ 'participant', 'type']
|
||||||
|
) || $indexAdded;
|
||||||
|
|
||||||
|
$indexAdded = $this->addIndex($schema,
|
||||||
|
'deck_cards',
|
||||||
|
'idx_due_notified_archived_deleted', [
|
||||||
|
'duedate', 'notified', 'archived', 'deleted_at'
|
||||||
|
],
|
||||||
|
) || $indexAdded;
|
||||||
|
|
||||||
|
$indexAdded = $this->addIndex($schema,
|
||||||
|
'deck_cards',
|
||||||
|
'idx_last_editor', [
|
||||||
|
'last_editor', 'description_prev'
|
||||||
|
], [],
|
||||||
|
// Adding a partial index on the description_prev as it is only used for a NULL check
|
||||||
|
['lengths' => [null, 1]]
|
||||||
|
) || $indexAdded;
|
||||||
|
|
||||||
|
$indexAdded = $this->addIndex($schema,
|
||||||
|
'deck_attachment',
|
||||||
|
'idx_cardid_deletedat',
|
||||||
|
[ 'card_id', 'deleted_at']
|
||||||
|
) || $indexAdded;
|
||||||
|
|
||||||
|
$indexAdded = $this->addIndex($schema,
|
||||||
|
'deck_assigned_users',
|
||||||
|
'idx_card_participant',
|
||||||
|
[ 'card_id', 'participant']
|
||||||
|
) || $indexAdded;
|
||||||
|
|
||||||
|
return $indexAdded ? $schema : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function addIndex(ISchemaWrapper $schema, string $table, string $indexName, array $columns, array $flags = [], array $options = []): bool {
|
||||||
|
$table = $schema->getTable($table);
|
||||||
|
if (!$table->hasIndex($indexName)) {
|
||||||
|
$table->addIndex($columns, $indexName, $flags, $options);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<files psalm-version="4.16.1@aa7e400908833b10c0333861f86cd48c510b60eb">
|
<files psalm-version="4.22.0@fc2c6ab4d5fa5d644d8617089f012f3bb84b8703">
|
||||||
<file src="lib/Activity/ActivityManager.php">
|
<file src="lib/Activity/ActivityManager.php">
|
||||||
<TypeDoesNotContainType occurrences="1">
|
<TypeDoesNotContainType occurrences="1">
|
||||||
<code>$message !== null</code>
|
<code>$message !== null</code>
|
||||||
@@ -10,17 +10,6 @@
|
|||||||
<code>(int)$subjectParams['comment']</code>
|
<code>(int)$subjectParams['comment']</code>
|
||||||
</InvalidScalarArgument>
|
</InvalidScalarArgument>
|
||||||
</file>
|
</file>
|
||||||
<file src="lib/AppInfo/Application.php">
|
|
||||||
<InvalidArgument occurrences="7">
|
|
||||||
<code>registerEventListener</code>
|
|
||||||
<code>registerEventListener</code>
|
|
||||||
<code>registerEventListener</code>
|
|
||||||
<code>registerEventListener</code>
|
|
||||||
<code>registerEventListener</code>
|
|
||||||
<code>registerEventListener</code>
|
|
||||||
<code>registerEventListener</code>
|
|
||||||
</InvalidArgument>
|
|
||||||
</file>
|
|
||||||
<file src="lib/Command/UserExport.php">
|
<file src="lib/Command/UserExport.php">
|
||||||
<ImplementedReturnTypeMismatch occurrences="1">
|
<ImplementedReturnTypeMismatch occurrences="1">
|
||||||
<code>void</code>
|
<code>void</code>
|
||||||
@@ -49,11 +38,6 @@
|
|||||||
<code>$this->userId</code>
|
<code>$this->userId</code>
|
||||||
</UndefinedThisPropertyFetch>
|
</UndefinedThisPropertyFetch>
|
||||||
</file>
|
</file>
|
||||||
<file src="lib/Controller/BoardController.php">
|
|
||||||
<UndefinedDocblockClass occurrences="1">
|
|
||||||
<code>\OCP\Deck\DB\Board</code>
|
|
||||||
</UndefinedDocblockClass>
|
|
||||||
</file>
|
|
||||||
<file src="lib/Controller/CommentsApiController.php">
|
<file src="lib/Controller/CommentsApiController.php">
|
||||||
<InvalidScalarArgument occurrences="6">
|
<InvalidScalarArgument occurrences="6">
|
||||||
<code>$cardId</code>
|
<code>$cardId</code>
|
||||||
@@ -107,11 +91,6 @@
|
|||||||
<code>$cardId</code>
|
<code>$cardId</code>
|
||||||
</ParamNameMismatch>
|
</ParamNameMismatch>
|
||||||
</file>
|
</file>
|
||||||
<file src="lib/Db/AttachmentMapper.php">
|
|
||||||
<UndefinedVariable occurrences="1">
|
|
||||||
<code>$query</code>
|
|
||||||
</UndefinedVariable>
|
|
||||||
</file>
|
|
||||||
<file src="lib/Db/BoardMapper.php">
|
<file src="lib/Db/BoardMapper.php">
|
||||||
<ParamNameMismatch occurrences="1">
|
<ParamNameMismatch occurrences="1">
|
||||||
<code>$boardId</code>
|
<code>$boardId</code>
|
||||||
@@ -184,6 +163,11 @@
|
|||||||
<code>$stackId</code>
|
<code>$stackId</code>
|
||||||
</ParamNameMismatch>
|
</ParamNameMismatch>
|
||||||
</file>
|
</file>
|
||||||
|
<file src="lib/Migration/Version10800Date20220422061816.php">
|
||||||
|
<MoreSpecificImplementedParamType occurrences="1">
|
||||||
|
<code>$schemaClosure</code>
|
||||||
|
</MoreSpecificImplementedParamType>
|
||||||
|
</file>
|
||||||
<file src="lib/Notification/Notifier.php">
|
<file src="lib/Notification/Notifier.php">
|
||||||
<RedundantCast occurrences="4">
|
<RedundantCast occurrences="4">
|
||||||
<code>(string) $l->t('%s has mentioned you in a comment on "%s".', [$dn, $params[0]])</code>
|
<code>(string) $l->t('%s has mentioned you in a comment on "%s".', [$dn, $params[0]])</code>
|
||||||
|
|||||||
Reference in New Issue
Block a user