diff --git a/lib/Migration/Version10800Date20220422061816.php b/lib/Migration/Version10800Date20220422061816.php new file mode 100644 index 000000000..c952da3d6 --- /dev/null +++ b/lib/Migration/Version10800Date20220422061816.php @@ -0,0 +1,99 @@ + + * + * @author Your name + * + * @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 . + * + */ + +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; + } +} diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index a0f44facc..9c34589b5 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -1,5 +1,5 @@ - + $message !== null @@ -10,17 +10,6 @@ (int)$subjectParams['comment'] - - - registerEventListener - registerEventListener - registerEventListener - registerEventListener - registerEventListener - registerEventListener - registerEventListener - - void @@ -49,11 +38,6 @@ $this->userId - - - \OCP\Deck\DB\Board - - $cardId @@ -107,11 +91,6 @@ $cardId - - - $query - - $boardId @@ -184,6 +163,11 @@ $stackId + + + $schemaClosure + + (string) $l->t('%s has mentioned you in a comment on "%s".', [$dn, $params[0]])