diff --git a/core/Application.php b/core/Application.php index d987f7cfb17b2..4e36d59baac42 100644 --- a/core/Application.php +++ b/core/Application.php @@ -196,6 +196,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 348b4f94f0d56..57fa49149f6b2 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -326,6 +326,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 4fa8fb3d1e960..3d97ee1de39c7 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -525,6 +525,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')) {