--- a/Command/CreateSchemaDoctrineCommand.php Fri Nov 18 17:54:30 2011 +0100
+++ b/Command/CreateSchemaDoctrineCommand.php Fri Nov 25 18:55:42 2011 +0100
@@ -21,6 +21,7 @@
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand;
use Symfony\Bundle\DoctrineBundle\Command\Proxy\DoctrineCommandHelper;
+use IRI\Bundle\WikiTagBundle\Utils\FilteredSchemaTool;
/**
* Command to execute the SQL needed to generate the database schema for
@@ -78,42 +79,14 @@
$this->container = $container;
}
-
- protected function filterCreateSchema($sqls)
- {
- // get service
- $schema_utils = $this->getContainer()->get("wikitag.shema_utils");
-
- $res_sqls = $schema_utils->filter_foreign_key($sqls);
- $res_sqls = $schema_utils->filter_index_creation($res_sqls);
-
-
- return $res_sqls;
- }
-
protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
{
- $output->write('ATTENTION: This operation should not be executed in a production environment.' . PHP_EOL . PHP_EOL);
- $sqls = $schemaTool->getCreateSchemaSql($metadatas);
- $createSchemaSql = $this->filterCreateSchema($sqls);
+ $filteredSchemaTool = new FilteredSchemaTool($this->getHelper("em")->getEntityManager(), $this->getContainer());
- if ($input->getOption('dump-sql') === true) {
-
- $output->write(implode(';' . PHP_EOL, $createSchemaSql) . PHP_EOL);
- } else {
- $output->write('Creating database schema...' . PHP_EOL);
- $emHelper = $this->getHelper('em');
-
- $conn = $emHelper->getEntityManager()->getConnection();
-
- foreach ($createSchemaSql as $sql) {
- $conn->executeQuery($sql);
- }
- $output->write('Database schema created successfully!' . PHP_EOL);
- }
-
+ parent::executeSchemaCommand($input, $output, $filteredSchemaTool, $metadatas);
+
}
protected function execute(InputInterface $input, OutputInterface $output)