Skip to content

Commit 4946e7c

Browse files
committed
Add index to oc_properties
Signed-off-by: Mario Danic <mario@lovelyhq.com>
1 parent 80222e6 commit 4946e7c

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

core/Command/Db/AddMissingIndices.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* @author Robin Appelman <robin@icewind.nl>
1212
* @author Roeland Jago Douma <roeland@famdouma.nl>
1313
* @author Thomas Citharel <nextcloud@tcit.fr>
14+
* @author Mario Danic <mario@lovelyhq.com>
1415
*
1516
* @license GNU AGPL version 3 or any later version
1617
*
@@ -254,6 +255,19 @@ private function addCoreIndexes(OutputInterface $output) {
254255
}
255256
}
256257

258+
$output->writeln('<info>Check indices of the oc_properties table.</info>');
259+
if ($schema->hasTable('oc_properties')) {
260+
$table = $schema->getTable('oc_properties');
261+
if (!$table->hasIndex('properties_path_index')) {
262+
$output->writeln('<info>Adding properties_path_index index to the oc_properties table, this can take some time...</info>');
263+
264+
$table->addIndex(['userid', 'propertypath'], 'properties_path_index');
265+
$this->connection->migrateToSchema($schema->getWrappedSchema());
266+
$updated = true;
267+
$output->writeln('<info>oc_properties table updated successfully.</info>');
268+
}
269+
}
270+
257271
if (!$updated) {
258272
$output->writeln('<info>Done.</info>');
259273
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace OC\Core\Migrations;
6+
7+
use Closure;
8+
use OCP\DB\ISchemaWrapper;
9+
use OCP\Migration\IOutput;
10+
use OCP\Migration\SimpleMigrationStep;
11+
12+
class Version19000Date20200429140134 extends SimpleMigrationStep {
13+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
14+
/** @var ISchemaWrapper $schema */
15+
$schema = $schemaClosure();
16+
17+
if ($schema->hasTable('oc_properties')) {
18+
$table = $schema->getTable('oc_properties');
19+
$table->addIndex(['userid', 'propertypath'], 'properties_path_index');
20+
}
21+
return $schema;
22+
}
23+
}

0 commit comments

Comments
 (0)