. */ namespace Doctrine\ORM\Tools\Console\Command; use Symfony\Components\Console\Input\InputArgument, Symfony\Components\Console\Input\InputOption, Symfony\Components\Console; /** * Validate that the current mapping is valid * * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.doctrine-project.com * @since 1.0 * @version $Revision$ * @author Benjamin Eberlei * @author Guilherme Blanco * @author Jonathan Wage * @author Roman Borschel */ class ValidateSchemaCommand extends Console\Command\Command { /** * @see Console\Command\Command */ protected function configure() { $this->setName('orm:validate-schema') ->setDescription('Validate that the current metadata schema is valid.'); } /** * @param InputInterface $input * @param OutputInterface $output */ protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) { $emHelper = $this->getHelper('em'); /* @var $em \Doctrine\ORM\EntityManager */ $em = $emHelper->getEntityManager(); $metadatas = $em->getMetadataFactory()->getAllMetadata(); if ( ! empty($metadatas)) { // Create SchemaTool $tool = new \Doctrine\ORM\Tools\SchemaTool($em); $updateSql = $tool->getUpdateSchemaSql($metadatas, false); if (count($updateSql) == 0) { $output->write("[Database] OK - Metadata schema exactly matches the database schema."); } else { $output->write("[Database] FAIL - There are differences between metadata and database schema."); } } else { $output->write("No metadata mappings found"); } } }