make occ command more generic

Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
Bjoern Schiessle 2017-12-15 10:45:00 +01:00 committed by Roeland Jago Douma
parent de98581421
commit 41ee23a054
No known key found for this signature in database
GPG key ID: F941078878347C0C
2 changed files with 26 additions and 8 deletions

View file

@ -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;
}
}

View file

@ -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()));