|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Symfony package. |
|
5 * |
|
6 * (c) Fabien Potencier <fabien@symfony.com> |
|
7 * |
|
8 * For the full copyright and license information, please view the LICENSE |
|
9 * file that was distributed with this source code. |
|
10 */ |
|
11 |
|
12 namespace Symfony\Bundle\DoctrineBundle\Command\Proxy; |
|
13 |
|
14 use Symfony\Component\Console\Input\InputArgument; |
|
15 use Symfony\Component\Console\Input\InputOption; |
|
16 use Symfony\Component\Console\Input\InputInterface; |
|
17 use Symfony\Component\Console\Output\OutputInterface; |
|
18 use Symfony\Component\Console\Output\Output; |
|
19 use Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand; |
|
20 |
|
21 /** |
|
22 * Command to generate the SQL needed to update the database schema to match |
|
23 * the current mapping information. |
|
24 * |
|
25 * @author Fabien Potencier <fabien@symfony.com> |
|
26 * @author Jonathan H. Wage <jonwage@gmail.com> |
|
27 */ |
|
28 class UpdateSchemaDoctrineCommand extends UpdateCommand |
|
29 { |
|
30 protected function configure() |
|
31 { |
|
32 parent::configure(); |
|
33 |
|
34 $this |
|
35 ->setName('doctrine:schema:update') |
|
36 ->setDescription('Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata') |
|
37 ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command') |
|
38 ->setHelp(<<<EOT |
|
39 The <info>doctrine:schema:update</info> command generates the SQL needed to |
|
40 synchronize the database schema with the current mapping metadata of the |
|
41 default entity manager. |
|
42 |
|
43 For example, if you add metadata for a new column to an entity, this command |
|
44 would generate and output the SQL needed to add the new column to the database: |
|
45 |
|
46 <info>php app/console doctrine:schema:update --dump-sql</info> |
|
47 |
|
48 Alternatively, you can execute the generated queries: |
|
49 |
|
50 <info>php app/console doctrine:schema:update --force</info> |
|
51 |
|
52 You can also update the database schema for a specific entity manager: |
|
53 |
|
54 <info>php app/console doctrine:schema:update --em=default</info> |
|
55 EOT |
|
56 ); |
|
57 } |
|
58 |
|
59 protected function execute(InputInterface $input, OutputInterface $output) |
|
60 { |
|
61 DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em')); |
|
62 |
|
63 parent::execute($input, $output); |
|
64 } |
|
65 } |