]> source.dussan.org Git - nextcloud-server.git/commitdiff
DB mounts table: Add index for mount_provider_class 34798/head
authorMarcel Klehr <mklehr@gmx.net>
Fri, 29 Jul 2022 12:43:26 +0000 (14:43 +0200)
committerMarcel Klehr <mklehr@gmx.net>
Thu, 27 Oct 2022 09:56:37 +0000 (11:56 +0200)
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
core/Application.php
core/Command/Db/AddMissingIndices.php
core/Migrations/Version24000Date20220202150027.php

index 34932cab183994edfe6786b2f1f12f70c6de2ade..8775b9cf88be415e9585701923dbeabcfcbf25e3 100644 (file)
@@ -218,6 +218,13 @@ class Application extends App {
                                                $subject->addHintForMissingSubject($table->getName(), 'direct_edit_timestamp');
                                        }
                                }
+
+                               if ($schema->hasTable('mounts')) {
+                                       $table = $schema->getTable('mounts');
+                                       if (!$table->hasIndex('mounts_class_index')) {
+                                               $subject->addHintForMissingSubject($table->getName(), 'mounts_class_index');
+                                       }
+                               }
                        }
                );
 
index a4379ffacc3bec3800e40b81a7df69d1b28a0d3f..c31acdb1225377ea53414dbf610dc824ddd1f347 100644 (file)
@@ -435,6 +435,22 @@ class AddMissingIndices extends Command {
                        }
                }
 
+               $output->writeln('<info>Check indices of the oc_mounts table.</info>');
+               if ($schema->hasTable('mounts')) {
+                       $table = $schema->getTable('mounts');
+                       if (!$table->hasIndex('mounts_class_index')) {
+                               $output->writeln('<info>Adding mounts_class_index index to the oc_mounts table, this can take some time...</info>');
+
+                               $table->addIndex(['mount_provider_class'], 'mounts_class_index');
+                               $sqlQueries = $this->connection->migrateToSchema($schema->getWrappedSchema(), $dryRun);
+                               if ($dryRun && $sqlQueries !== null) {
+                                       $output->writeln($sqlQueries);
+                               }
+                               $updated = true;
+                               $output->writeln('<info>oc_mounts table updated successfully.</info>');
+                       }
+               }
+
                if (!$updated) {
                        $output->writeln('<info>Done.</info>');
                }
index 76a3ae8c73c1eff028e8a1575363674c9cdcd58e..6a3f5ad2faf9b9d99eec9e33aee643242584cc25 100644 (file)
@@ -30,6 +30,7 @@ class Version24000Date20220202150027 extends SimpleMigrationStep {
                                'notnull' => false,
                                'length' => 128,
                        ]);
+                       $table->addIndex(['mount_provider_class'], 'mounts_class_index');
                        return $schema;
                }
                return null;