Skip to content

Commit

Permalink
Add index to properties table
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Danic <[email protected]>
  • Loading branch information
mario committed Apr 30, 2020
1 parent 8d5404b commit 6e28c28
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ function (GenericEvent $event) use ($container) {
$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');
}
}
}
);

Expand Down
14 changes: 14 additions & 0 deletions core/Command/Db/AddMissingIndices.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @author Robin Appelman <[email protected]>
* @author Roeland Jago Douma <[email protected]>
* @author Thomas Citharel <[email protected]>
* @author Mario Danic <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
Expand Down Expand Up @@ -254,6 +255,19 @@ private function addCoreIndexes(OutputInterface $output) {
}
}

$output->writeln('<info>Check indices of the oc_properties table.</info>');
if ($schema->hasTable('properties')) {
$table = $schema->getTable('properties');
if (!$table->hasIndex('properties_path_index')) {
$output->writeln('<info>Adding properties_path_index index to the oc_properties table, this can take some time...</info>');

$table->addIndex(['userid', 'propertypath'], 'properties_path_index');
$this->connection->migrateToSchema($schema->getWrappedSchema());
$updated = true;
$output->writeln('<info>oc_properties table updated successfully.</info>');
}
}

if (!$updated) {
$output->writeln('<info>Done.</info>');
}
Expand Down
1 change: 1 addition & 0 deletions core/Migrations/Version13000Date20170718121200.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['userid'], 'property_index');
$table->addIndex(['userid', 'propertypath'], 'properties_path_index');
}

if (!$schema->hasTable('share')) {
Expand Down

0 comments on commit 6e28c28

Please sign in to comment.