diff --git a/core/Application.php b/core/Application.php
index 0f363f8c699ce..78408eb8353e9 100644
--- a/core/Application.php
+++ b/core/Application.php
@@ -206,6 +206,13 @@ function (GenericEvent $event) use ($container) {
$subject->addHintForMissingSubject($table->getName(), 'job_lastcheck_reserved');
}
}
+
+ if ($schema->hasTable('preferences')) {
+ $table = $schema->getTable('preferences');
+ if (!$table->hasIndex('preferences_app_key')) {
+ $subject->addHintForMissingSubject($table->getName(), 'preferences_app_key');
+ }
+ }
}
);
diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php
index 4c86a8705db42..875dcb859216d 100644
--- a/core/Command/Db/AddMissingIndices.php
+++ b/core/Command/Db/AddMissingIndices.php
@@ -352,6 +352,19 @@ private function addCoreIndexes(OutputInterface $output) {
}
}
+ $output->writeln('Check indices of the oc_preferences table.');
+ if ($schema->hasTable('preferences')) {
+ $table = $schema->getTable('preferences');
+ if (!$table->hasIndex('preferences_app_key')) {
+ $output->writeln('Adding preferences_app_key index to the oc_preferences table, this can take some time...');
+
+ $table->addIndex(['appid', 'configkey'], 'preferences_app_key');
+ $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 02864830b2cdf..3e14b4af47adb 100644
--- a/core/Migrations/Version13000Date20170718121200.php
+++ b/core/Migrations/Version13000Date20170718121200.php
@@ -333,6 +333,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
'notnull' => false,
]);
$table->setPrimaryKey(['userid', 'appid', 'configkey']);
+ $table->addIndex(['appid', 'configkey'], 'preferences_app_key');
}
if (!$schema->hasTable('properties')) {