]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add index to properties table 20716/head
authorMario Danic <mario@lovelyhq.com>
Wed, 29 Apr 2020 22:13:13 +0000 (00:13 +0200)
committerMario Danic <mario@lovelyhq.com>
Thu, 30 Apr 2020 21:04:15 +0000 (23:04 +0200)
Signed-off-by: Mario Danic <mario@lovelyhq.com>
core/Application.php
core/Command/Db/AddMissingIndices.php
core/Migrations/Version13000Date20170718121200.php

index 2996c4125538a65becb4ca9c3da6f346b9c0f635..217b6ac41e9a643595c3f5791b8a877ca8eea733 100644 (file)
@@ -163,6 +163,13 @@ class Application extends App {
                                                $subject->addHintForMissingSubject($table->getName(), 'schedulobj_principuri_index');
                                        }
                                }
+
+                               if ($schema->hasTable('properties')) {
+                                       $table = $schema->getTable('properties');
+                                       if (!$table->hasIndex('properties_path_index')) {
+                                               $subject->addHintForMissingSubject($table->getName(), 'properties_path_index');
+                                       }
+                               }
                        }
                );
 
index 506fef94a63a0135edf788ad744a78565f81077a..2784721f55fd4c3ff516a75ad760d7913e9eee56 100644 (file)
@@ -11,6 +11,7 @@ declare(strict_types=1);
  * @author Robin Appelman <robin@icewind.nl>
  * @author Roeland Jago Douma <roeland@famdouma.nl>
  * @author Thomas Citharel <nextcloud@tcit.fr>
+ * @author Mario Danic <mario@lovelyhq.com>
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -254,6 +255,19 @@ class AddMissingIndices extends Command {
                        }
                }
 
+               $output->writeln('<info>Check indices of the oc_properties table.</info>');
+               if ($schema->hasTable('properties')) {
+                       $table = $schema->getTable('properties');
+                       if (!$table->hasIndex('properties_path_index')) {
+                               $output->writeln('<info>Adding properties_path_index index to the oc_properties table, this can take some time...</info>');
+
+                               $table->addIndex(['userid', 'propertypath'], 'properties_path_index');
+                               $this->connection->migrateToSchema($schema->getWrappedSchema());
+                               $updated = true;
+                               $output->writeln('<info>oc_properties table updated successfully.</info>');
+                       }
+               }
+
                if (!$updated) {
                        $output->writeln('<info>Done.</info>');
                }
index f9745566168906a2bb7eeb801f2b237ddfc7bb38..7e48059f7982a3686f94d60b17b1c19b8671c1a4 100644 (file)
@@ -318,6 +318,7 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
                        ]);
                        $table->setPrimaryKey(['id']);
                        $table->addIndex(['userid'], 'property_index');
+                       $table->addIndex(['userid', 'propertypath'], 'properties_path_index');
                }
 
                if (!$schema->hasTable('share')) {