diff --git a/core/Application.php b/core/Application.php index f0478173d43dd..460a645f10c14 100644 --- a/core/Application.php +++ b/core/Application.php @@ -187,6 +187,13 @@ function (GenericEvent $event) use ($container) { $subject->addHintForMissingSubject($table->getName(), 'properties_path_index'); } } + + if ($schema->hasTable('jobs')) { + $table = $schema->getTable('jobs'); + if (!$table->hasIndex('job_lastcheck_reserved')) { + $subject->addHintForMissingSubject($table->getName(), 'job_lastcheck_reserved'); + } + } } ); diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index 2e6b3dc9aeb34..79269a01f53a4 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -311,6 +311,19 @@ private function addCoreIndexes(OutputInterface $output) { } } + $output->writeln('Check indices of the oc_jobs table.'); + if ($schema->hasTable('jobs')) { + $table = $schema->getTable('jobs'); + if (!$table->hasIndex('job_lastcheck_reserved')) { + $output->writeln('Adding job_lastcheck_reserved index to the oc_jobs table, this can take some time...'); + + $table->addIndex(['last_checked', 'reserved_at'], 'job_lastcheck_reserved'); + $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 7b959c6073cb9..a6ff1cbfa9431 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -520,6 +520,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op ]); $table->setPrimaryKey(['id']); $table->addIndex(['class'], 'job_class_index'); + $table->addIndex(['last_checked', 'reserved_at'], 'job_lastcheck_reserved'); } if (!$schema->hasTable('users')) {