Browse Source

make occ command more generic

Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
pull/7517/head
Bjoern Schiessle 8 years ago
committed by Roeland Jago Douma
parent
commit
41ee23a054
No known key found for this signature in database GPG Key ID: F941078878347C0C
  1. 32
      core/Command/Db/AddMissingIndices.php
  2. 2
      core/register_command.php

32
core/Command/Db/AddIndexToShareTable.php → core/Command/Db/AddMissingIndices.php

@ -28,7 +28,15 @@ use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class AddIndexToShareTable extends Command {
/**
* Class AddMissingIndices
*
* if you added any new indices to the database, this is the right place to add
* it your update routine for existing instances
*
* @package OC\Core\Command\Db
*/
class AddMissingIndices extends Command {
/** @var IDBConnection */
private $connection;
@ -43,11 +51,24 @@ class AddIndexToShareTable extends Command {
protected function configure() {
$this
->setName('db:add-index-to-share-table')
->setDescription('Add a index to share_with at the share table to increase performance');
->setName('db:add-missing-indices')
->setDescription('Add missing indices to the database tables');
}
protected function execute(InputInterface $input, OutputInterface $output) {
$this->addShareTableIndicies($output);
}
/**
* add missing indices to the share table
*
* @param OutputInterface $output
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
private function addShareTableIndicies(OutputInterface $output) {
$output->writeln('<info>Check indices of the share table.</info>');
$schema = new SchemaWrapper($this->connection);
$updated = false;
@ -64,10 +85,7 @@ class AddIndexToShareTable extends Command {
}
if (!$updated) {
$output->writeln('<info>All index already existed, nothing to do.</info>');
$output->writeln('<info>Done.</info>');
}
return 0;
}
}

2
core/register_command.php

@ -90,7 +90,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
$application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig())));
$application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->getLogger()));
$application->add(new OC\Core\Command\Db\ConvertFilecacheBigInt(\OC::$server->getDatabaseConnection()));
$application->add(new OC\Core\Command\Db\AddIndexToShareTable(\OC::$server->getDatabaseConnection()));
$application->add(new OC\Core\Command\Db\AddMissingIndices(\OC::$server->getDatabaseConnection()));
$application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->getDatabaseConnection()));
$application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->getDatabaseConnection()));
$application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->getDatabaseConnection()));

Loading…
Cancel
Save