diff --git a/lib/Db/AddMissingIndices.php b/lib/Db/AddMissingIndices.php index 99d3d2da..98adabfa 100644 --- a/lib/Db/AddMissingIndices.php +++ b/lib/Db/AddMissingIndices.php @@ -17,6 +17,16 @@ class AddMissingIndices // Should migrate at end $shouldMigrate = false; + // Speed up CTE lookup for subdirectories + if ($schema->hasTable('filecache')) { + $table = $schema->getTable('filecache'); + + if (!$table->hasIndex('memories_parent_mimetype')) { + $table->addIndex(['parent', 'mimetype'], 'memories_parent_mimetype'); + $shouldMigrate = true; + } + } + // Add index on systemtag_object_mapping to speed up the query if ($schema->hasTable('systemtag_object_mapping')) { $table = $schema->getTable('systemtag_object_mapping'); diff --git a/lib/Migration/Version400308Date20221026151748.php b/lib/Migration/Version400308Date20221026151748.php index ee680f96..5b5748d3 100644 --- a/lib/Migration/Version400308Date20221026151748.php +++ b/lib/Migration/Version400308Date20221026151748.php @@ -42,15 +42,9 @@ class Version400308Date20221026151748 extends SimpleMigrationStep */ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options): ?ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - // Speed up CTE lookup for subdirectories - $fileCacheTable = $schema->getTable('filecache'); - $fileCacheTable->addIndex(['parent', 'mimetype'], 'memories_parent_mimetype'); - - // Add other indices - return $schema; + // Addition of memories_parent_mimetype moved to AddMissingIndices + // since this is on an external table (filecache) + return null; } /**