Applying variable naming scheme, returning schema only if changes are made for performance and removing the original

creation of the indicies for new installations

Signed-off-by: Rob Emery <git@mintsoft.net>
This commit is contained in:
Rob Emery
2024-02-29 09:02:08 +00:00
committed by Julius Härtl
parent d841c960a3
commit afb50574f7
2 changed files with 14 additions and 27 deletions

View File

@@ -271,7 +271,7 @@ class Version1000Date20200306161713 extends SimpleMigrationStep {
]); ]);
$table->setPrimaryKey(['id']); $table->setPrimaryKey(['id']);
$table->addIndex(['participant'], 'deck_assigned_users_idx_p'); $table->addIndex(['participant'], 'deck_assigned_users_idx_p');
$table->addIndex(['card_id'], 'deck_assigned_users_idx_c'); //$table->addIndex(['card_id'], 'deck_assigned_users_idx_c');
} }
if (!$schema->hasTable('deck_board_acl')) { if (!$schema->hasTable('deck_board_acl')) {
@@ -307,7 +307,7 @@ class Version1000Date20200306161713 extends SimpleMigrationStep {
]); ]);
$table->setPrimaryKey(['id']); $table->setPrimaryKey(['id']);
$table->addUniqueIndex(['board_id', 'type', 'participant'], 'deck_board_acl_uq_i'); $table->addUniqueIndex(['board_id', 'type', 'participant'], 'deck_board_acl_uq_i');
$table->addIndex(['board_id'], 'deck_board_acl_idx_i'); //$table->addIndex(['board_id'], 'deck_board_acl_idx_i');
} }
return $schema; return $schema;
} }

View File

@@ -1,22 +1,7 @@
<?php <?php
/** /**
* @copyright Copyright (c) 2022, chandi Langecker (git@chandi.it) * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* * SPDX-License-Identifier: AGPL-3.0-or-later
* @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/>.
*
*/ */
declare(strict_types=1); declare(strict_types=1);
@@ -26,23 +11,25 @@ namespace OCA\Deck\Migration;
use Closure; use Closure;
use OCP\DB\ISchemaWrapper; use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput; use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep; use OCP\Migration\SimpleMigrationStep;
class Version11000Date20240222115515 extends SimpleMigrationStep { class Version11000Date20240222115515 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
$schema = $schemaClosure(); $schema = $schemaClosure();
$returnValue = null;
$assigned_users_table = $schema->getTable('deck_assigned_users'); $assignedUsersTable = $schema->getTable('deck_assigned_users');
if($assigned_users_table->hasIndex('deck_assigned_users_idx_c')) { if($assignedUsersTable->hasIndex('deck_assigned_users_idx_c')) {
$assigned_users_table->dropIndex('deck_assigned_users_idx_c'); $assignedUsersTable->dropIndex('deck_assigned_users_idx_c');
$returnValue = $schema;
} }
$board_acl_table = $schema->getTable('deck_board_acl'); $boardAclTable = $schema->getTable('deck_board_acl');
if($board_acl_table->hasIndex('deck_board_acl_idx_i')) { if($boardAclTable->hasIndex('deck_board_acl_idx_i')) {
$board_acl_table->dropIndex('deck_board_acl_idx_i'); $boardAclTable->dropIndex('deck_board_acl_idx_i');
$returnValue = $schema;
} }
return $schema; return $returnValue;
} }
} }