Add migration to fix wrong index on type (fixes #1884)

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-11-11 16:09:28 +01:00
parent 746b34e6c7
commit bedbe30fd2
2 changed files with 38 additions and 1 deletions

View File

@@ -39,7 +39,8 @@ class Version1000Date20200308073933 extends SimpleMigrationStep {
'notnull' => true,
'default' => 0
]);
$table->addIndex(['participant'], 'deck_assigned_users_idx_t');
//$table->addIndex(['participant'], 'deck_assigned_users_idx_t');
$table->addIndex(['type'], 'deck_assigned_users_idx_ty');
return $schema;
}

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace OCA\Deck\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version10200Date20201111150114 extends SimpleMigrationStep {
function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
}
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
// Fix wrong index added in Version1000Date20200308073933
$table = $schema->getTable('deck_assigned_users');
if ($table->hasIndex('deck_assigned_users_idx_t')) {
$table->dropIndex('deck_assigned_users_idx_t');
if (!$table->hasIndex('deck_assigned_users_idx_ty')) {
$table->addIndex(['type'], 'deck_assigned_users_idx_ty');
}
}
return $schema;
}
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
}
}