Skip to content

Commit 8589206

Browse files
committed
Add skip-search-indexes option to schema CLI commands
Currently, commands can either process all definitions (default behavior) or specify individual definitions. This allows the commands to rely on default behavior (e.g. $createOrder) but omit processing of search indexes, which may be more stringent requirements. Note: this is similar to the disable-validators option that already existed in UpdateCommand; however, doctrine#2634 suggests renaming that if additional "skip" options are introduced.
1 parent 13155ae commit 8589206

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/CreateCommand.php

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ protected function configure()
4141
->addOption(self::COLLECTION, null, InputOption::VALUE_NONE, 'Create collections')
4242
->addOption(self::INDEX, null, InputOption::VALUE_NONE, 'Create indexes')
4343
->addOption(self::SEARCH_INDEX, null, InputOption::VALUE_NONE, 'Create search indexes')
44+
->addOption('skip-search-indexes', null, InputOption::VALUE_NONE, 'Skip processing of search indexes')
4445
->addOption('background', null, InputOption::VALUE_NONE, sprintf('Create indexes in background (requires "%s" option)', self::INDEX))
4546
->setDescription('Create databases, collections and indexes for your documents');
4647
}
@@ -65,6 +66,10 @@ private function doExecute(InputInterface $input, OutputInterface $output): int
6566
self::SEARCH_INDEX => 'SearchIndex',
6667
};
6768

69+
if ($option === self::SEARCH_INDEX && $input->getOption('skip-search-indexes')) {
70+
continue;
71+
}
72+
6873
try {
6974
if (isset($class)) {
7075
$this->{'processDocument' . $method}($sm, $class, $this->getMaxTimeMsFromInput($input), $this->getWriteConcernFromInput($input), $background);

lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/DropCommand.php

+5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ protected function configure()
4343
->addOption(self::COLLECTION, null, InputOption::VALUE_NONE, 'Drop collections')
4444
->addOption(self::INDEX, null, InputOption::VALUE_NONE, 'Drop indexes')
4545
->addOption(self::SEARCH_INDEX, null, InputOption::VALUE_NONE, 'Drop search indexes')
46+
->addOption('skip-search-indexes', null, InputOption::VALUE_NONE, 'Skip processing of search indexes')
4647
->setDescription('Drop databases, collections and indexes for your documents');
4748
}
4849

@@ -65,6 +66,10 @@ private function doExecute(InputInterface $input, OutputInterface $output): int
6566
self::SEARCH_INDEX => 'SearchIndex',
6667
};
6768

69+
if ($option === self::SEARCH_INDEX && $input->getOption('skip-search-indexes')) {
70+
continue;
71+
}
72+
6873
try {
6974
if (is_string($class)) {
7075
$this->{'processDocument' . $method}($sm, $class, $this->getMaxTimeMsFromInput($input), $this->getWriteConcernFromInput($input));

lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/UpdateCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected function configure()
2727
$this
2828
->setName('odm:schema:update')
2929
->addOption('class', 'c', InputOption::VALUE_OPTIONAL, 'Document class to process (default: all classes)')
30-
->addOption('disable-search-indexes', null, InputOption::VALUE_NONE, 'Do not update search indexes')
30+
->addOption('skip-search-indexes', null, InputOption::VALUE_NONE, 'Skip processing of search indexes')
3131
->addOption('disable-validators', null, InputOption::VALUE_NONE, 'Do not update database-level validation rules')
3232
->setDescription('Update indexes and validation rules for your documents');
3333
}
@@ -36,7 +36,7 @@ private function doExecute(InputInterface $input, OutputInterface $output): int
3636
{
3737
$class = $input->getOption('class');
3838
$updateValidators = ! $input->getOption('disable-validators');
39-
$updateSearchIndexes = ! $input->getOption('disable-search-indexes');
39+
$updateSearchIndexes = ! $input->getOption('skip-search-indexes');
4040

4141
$sm = $this->getSchemaManager();
4242
$isErrored = false;

0 commit comments

Comments
 (0)