DB: Improve performance using table indexes

fixes #678
This commit is contained in:
Marcel Klehr 2019-04-02 16:41:21 +02:00
parent 5dafff4637
commit 16b0b540c2
1 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,52 @@
<?php
namespace OCA\Bookmarks\Migration;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
use OCP\IDBConnection;
/**
* Auto-generated migration step: Please modify to your needs!
*/
class Version000016005Date20190402094721 extends SimpleMigrationStep {
private $db;
public function __construct(IDBConnection $db) {
$this->db = $db;
}
/**
* @param IOutput $output
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
}
/**
* @param IOutput $output
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('bookmarks_folders_bookmarks');
$table->addIndex(['bookmark_id']);
$table = $schema->getTable('bookmarks');
$table->addIndex(['user_id']);
$table = $schema->getTable('bookmarks_folders');
$table->addIndex(['user_id']);
return $schema;
}
/**
* @param IOutput $output
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
}
}