Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable10] Add index to oc_cards to assist with searching large numbe… #28042

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions apps/dav/appinfo/Migrations/Version20170519091921.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
namespace OCA\dav\Migrations;

use Doctrine\DBAL\Schema\Schema;
use OCP\Migration\ISchemaMigration;

/**
* Add index to oc_cards to assist with searching with large numbers of rows
*/
class Version20170519091921 implements ISchemaMigration {

public function changeSchema(Schema $schema, array $options) {
$prefix = $options['tablePrefix'];
$table = $schema->getTable("${prefix}cards");
// Check for existing index spanning these columns
foreach ($table->getIndexes() as $index) {
// Check if we have a matching index already
if(empty(array_diff($index->getColumns(), ['uri', 'addressbookid']))) {
return;
}

}
// Add the index if we dont have one spanning this column already
$table->addIndex(['addressbookid', 'uri'], 'addressbookid_uri_index');
}

}