setName(self::ROUTE) ->setDescription('Ensure database has correct indexes.') ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Do not commit changes.') ->addOption('force-reindex', 'f', InputOption::VALUE_NONE, 'Drop existing indexes, and re-create them.') ->setHelp( r( <<[ FAQ ] ------- # How to recreate the indexes? You can drop the current indexes and rebuild them by using the following command {cmd} {route} --force-reindex HELP, [ 'cmd' => trim(commandContext()), 'route' => self::ROUTE ] ) ); } /** * Run a command. * * @param InputInterface $input An instance of the InputInterface interface. * @param OutputInterface $output An instance of the OutputInterface interface. * * @return int The status code indicating the success or failure of the command execution. */ protected function runCommand(InputInterface $input, OutputInterface $output): int { $this->db->ensureIndex([ Options::DRY_RUN => (bool)$input->getOption('dry-run'), 'force-reindex' => (bool)$input->getOption('force-reindex'), ]); return self::SUCCESS; } }