Merge pull request #9620 from nextcloud/backport/9576/stable13
[stable13] Emit event when running ./occ db:add-missing-indices
This commit is contained in:
commit
b03752b1d9
|
@ -27,6 +27,8 @@ use OCP\IDBConnection;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AddMissingIndices
|
* Class AddMissingIndices
|
||||||
|
@ -41,12 +43,14 @@ class AddMissingIndices extends Command {
|
||||||
/** @var IDBConnection */
|
/** @var IDBConnection */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
/**
|
/** @var EventDispatcherInterface */
|
||||||
* @param IDBConnection $connection
|
private $dispatcher;
|
||||||
*/
|
|
||||||
public function __construct(IDBConnection $connection) {
|
public function __construct(IDBConnection $connection, EventDispatcherInterface $dispatcher) {
|
||||||
$this->connection = $connection;
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->connection = $connection;
|
||||||
|
$this->dispatcher = $dispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure() {
|
protected function configure() {
|
||||||
|
@ -58,6 +62,9 @@ class AddMissingIndices extends Command {
|
||||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||||
$this->addShareTableIndicies($output);
|
$this->addShareTableIndicies($output);
|
||||||
|
|
||||||
|
// Dispatch event so apps can also update indexes if needed
|
||||||
|
$event = new GenericEvent($output);
|
||||||
|
$this->dispatcher->dispatch(IDBConnection::ADD_MISSING_INDEXES_EVENT, $event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,8 +80,8 @@ class AddMissingIndices extends Command {
|
||||||
$schema = new SchemaWrapper($this->connection);
|
$schema = new SchemaWrapper($this->connection);
|
||||||
$updated = false;
|
$updated = false;
|
||||||
|
|
||||||
if ($schema->hasTable("share")) {
|
if ($schema->hasTable('share')) {
|
||||||
$table = $schema->getTable("share");
|
$table = $schema->getTable('share');
|
||||||
if (!$table->hasIndex('share_with_index')) {
|
if (!$table->hasIndex('share_with_index')) {
|
||||||
$output->writeln('<info>Adding additional index to the share table, this can take some time...</info>');
|
$output->writeln('<info>Adding additional index to the share table, this can take some time...</info>');
|
||||||
$table->addIndex(['share_with'], 'share_with_index');
|
$table->addIndex(['share_with'], 'share_with_index');
|
||||||
|
|
|
@ -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\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\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\ConvertFilecacheBigInt(\OC::$server->getDatabaseConnection()));
|
||||||
$application->add(new OC\Core\Command\Db\AddMissingIndices(\OC::$server->getDatabaseConnection()));
|
$application->add(new OC\Core\Command\Db\AddMissingIndices(\OC::$server->getDatabaseConnection(), \OC::$server->getEventDispatcher()));
|
||||||
$application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\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\MigrateCommand(\OC::$server->getDatabaseConnection()));
|
||||||
$application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->getDatabaseConnection()));
|
$application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->getDatabaseConnection()));
|
||||||
|
|
|
@ -45,6 +45,9 @@ use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
*/
|
*/
|
||||||
interface IDBConnection {
|
interface IDBConnection {
|
||||||
|
|
||||||
|
const ADD_MISSING_INDEXES_EVENT = self::class . '::ADD_MISSING_INDEXES';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the QueryBuilder for the connection.
|
* Gets the QueryBuilder for the connection.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue