From 6e28c2807b751a9dbd2a60abb3038eed3cf04b42 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Thu, 30 Apr 2020 00:13:13 +0200 Subject: [PATCH] Add index to properties table Signed-off-by: Mario Danic --- core/Application.php | 7 +++++++ core/Command/Db/AddMissingIndices.php | 14 ++++++++++++++ core/Migrations/Version13000Date20170718121200.php | 1 + 3 files changed, 22 insertions(+) diff --git a/core/Application.php b/core/Application.php index 2996c41255..217b6ac41e 100644 --- a/core/Application.php +++ b/core/Application.php @@ -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'); + } + } } ); diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index 506fef94a6..2784721f55 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -11,6 +11,7 @@ declare(strict_types=1); * @author Robin Appelman * @author Roeland Jago Douma * @author Thomas Citharel + * @author Mario Danic * * @license GNU AGPL version 3 or any later version * @@ -254,6 +255,19 @@ class AddMissingIndices extends Command { } } + $output->writeln('Check indices of the oc_properties table.'); + if ($schema->hasTable('properties')) { + $table = $schema->getTable('properties'); + if (!$table->hasIndex('properties_path_index')) { + $output->writeln('Adding properties_path_index index to the oc_properties table, this can take some time...'); + + $table->addIndex(['userid', 'propertypath'], 'properties_path_index'); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('oc_properties table updated successfully.'); + } + } + if (!$updated) { $output->writeln('Done.'); } diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php index f974556616..7e48059f79 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -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')) {