setName('db:schema:check')
->setDescription('Compare the live database schema against the schema expected for the currently installed version')
->setHelp("Note that the expected schema might not exactly match the live schema as the expected schema doesn't take into account any database wide settings or defaults.")
->addArgument('table', InputArgument::OPTIONAL, 'Only check the schema for the specified table');
parent::configure();
}
#[Override]
protected function execute(InputInterface $input, OutputInterface $output): int {
$onlyTable = $input->getArgument('table');
$findings = $this->schemaChecker->getFindings($onlyTable);
if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) {
if ($findings === []) {
$output->writeln('The live database schema matches the expected schema.');
} else {
foreach ($findings as $finding) {
$output->writeln('' . $this->schemaChecker->formatFinding($finding) . '');
}
}
} else {
$this->writeArrayInOutputFormat($input, $output, $findings);
}
return $findings === [] ? 0 : 1;
}
}