. */ namespace Doctrine\ORM\Tools\Console\Command\SchemaTool; use Symfony\Component\Console\Input\InputArgument, Symfony\Component\Console\Input\InputOption, Symfony\Component\Console\Input\InputInterface, Symfony\Component\Console\Output\OutputInterface, Doctrine\ORM\Tools\SchemaTool; /** * Command to create the database schema for a set of classes based on their mappings. * * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.doctrine-project.org * @since 2.0 * @version $Revision$ * @author Benjamin Eberlei * @author Guilherme Blanco * @author Jonathan Wage * @author Roman Borschel */ class CreateCommand extends AbstractCommand { /** * @see Console\Command\Command */ protected function configure() { $this ->setName('orm:schema-tool:create') ->setDescription( 'Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output.' ) ->setDefinition(array( new InputOption( 'dump-sql', null, InputOption::VALUE_NONE, 'Instead of try to apply generated SQLs into EntityManager Storage Connection, output them.' ) )) ->setHelp(<<write('ATTENTION: This operation should not be executed in an production enviroment.' . PHP_EOL . PHP_EOL); if ($input->getOption('dump-sql') === true) { $sqls = $schemaTool->getCreateSchemaSql($metadatas); $output->write(implode(';' . PHP_EOL, $sqls) . PHP_EOL); } else { $output->write('Creating database schema...' . PHP_EOL); $schemaTool->createSchema($metadatas); $output->write('Database schema created successfully!' . PHP_EOL); } } }