@@ 5-57 (lines=53) @@ | ||
2 | ||
3 | use Symfony\Component\Console\Input\InputOption; |
|
4 | ||
5 | class SchemaCreateCommand extends DoctrineSchemaCommand |
|
6 | { |
|
7 | ||
8 | /** |
|
9 | * @var string |
|
10 | */ |
|
11 | protected $name = 'doctrine:schema:create'; |
|
12 | ||
13 | /** |
|
14 | * @var string |
|
15 | */ |
|
16 | protected $description = 'Create database schema from entities'; |
|
17 | ||
18 | ||
19 | /** |
|
20 | * @inheritdoc |
|
21 | * @throws \Doctrine\ORM\Tools\ToolsException |
|
22 | */ |
|
23 | public function fire() |
|
24 | { |
|
25 | $tool = $this->getSchemaTool(); |
|
26 | $metadata = $this->getEntityManager()->getMetadataFactory()->getAllMetadata(); |
|
27 | ||
28 | $sql = $tool->getCreateSchemaSql($metadata); |
|
29 | ||
30 | if (count($sql) === 0) { |
|
31 | $this->info('Nothing to create!'); |
|
32 | ||
33 | return; |
|
34 | } |
|
35 | ||
36 | $this->info('Creating database schema ...'); |
|
37 | ||
38 | $tool->createSchema($metadata); |
|
39 | ||
40 | if ($this->option('sql')) { |
|
41 | $this->info(implode(';' . PHP_EOL, $sql)); |
|
42 | } |
|
43 | ||
44 | $this->info('Schema created!'); |
|
45 | } |
|
46 | ||
47 | ||
48 | /** |
|
49 | * @return array |
|
50 | */ |
|
51 | protected function getOptions() |
|
52 | { |
|
53 | return [ |
|
54 | ['sql', false, InputOption::VALUE_NONE, 'Dumps SQL queries.'], |
|
55 | ]; |
|
56 | } |
|
57 | } |
|
58 |
@@ 5-57 (lines=53) @@ | ||
2 | ||
3 | use Symfony\Component\Console\Input\InputOption; |
|
4 | ||
5 | class SchemaDropCommand extends DoctrineSchemaCommand |
|
6 | { |
|
7 | ||
8 | /** |
|
9 | * @var string |
|
10 | */ |
|
11 | protected $name = 'doctrine:schema:drop'; |
|
12 | ||
13 | /** |
|
14 | * @var string |
|
15 | */ |
|
16 | protected $description = 'Drop database schema'; |
|
17 | ||
18 | ||
19 | /** |
|
20 | * @inheritdoc |
|
21 | * @throws \Doctrine\ORM\Tools\ToolsException |
|
22 | */ |
|
23 | public function fire() |
|
24 | { |
|
25 | $tool = $this->getSchemaTool(); |
|
26 | $metadata = $this->getEntityManager()->getMetadataFactory()->getAllMetadata(); |
|
27 | ||
28 | $sql = $tool->getDropSchemaSQL($metadata); |
|
29 | ||
30 | if (count($sql) === 0) { |
|
31 | $this->info('Nothing to drop!'); |
|
32 | ||
33 | return; |
|
34 | } |
|
35 | ||
36 | $this->info('Dropping database schema ...'); |
|
37 | ||
38 | $tool->dropSchema($metadata); |
|
39 | ||
40 | if ($this->option('sql')) { |
|
41 | $this->info(implode(';' . PHP_EOL, $sql)); |
|
42 | } |
|
43 | ||
44 | $this->info('Schema dropped!'); |
|
45 | } |
|
46 | ||
47 | ||
48 | /** |
|
49 | * @return array |
|
50 | */ |
|
51 | protected function getOptions() |
|
52 | { |
|
53 | return [ |
|
54 | ['sql', false, InputOption::VALUE_NONE, 'Dumps SQL queries.'], |
|
55 | ]; |
|
56 | } |
|
57 | } |
|
58 |
@@ 5-56 (lines=52) @@ | ||
2 | ||
3 | use Symfony\Component\Console\Input\InputOption; |
|
4 | ||
5 | class SchemaUpdateCommand extends DoctrineSchemaCommand |
|
6 | { |
|
7 | ||
8 | /** |
|
9 | * @var string |
|
10 | */ |
|
11 | protected $name = 'doctrine:schema:update'; |
|
12 | ||
13 | /** |
|
14 | * @var string |
|
15 | */ |
|
16 | protected $description = 'Update database schema to match entities'; |
|
17 | ||
18 | ||
19 | /** |
|
20 | * @inheritdoc |
|
21 | */ |
|
22 | public function fire() |
|
23 | { |
|
24 | $tool = $this->getSchemaTool(); |
|
25 | $metadata = $this->getEntityManager()->getMetadataFactory()->getAllMetadata(); |
|
26 | ||
27 | $sql = $tool->getUpdateSchemaSql($metadata); |
|
28 | ||
29 | if (count($sql) === 0) { |
|
30 | $this->info('Nothing to update!'); |
|
31 | ||
32 | return; |
|
33 | } |
|
34 | ||
35 | $this->info('Updating database schema ...'); |
|
36 | ||
37 | $tool->updateSchema($metadata); |
|
38 | ||
39 | if ($this->option('sql')) { |
|
40 | $this->info(implode(';' . PHP_EOL, $sql)); |
|
41 | } |
|
42 | ||
43 | $this->info('Schema updated!'); |
|
44 | } |
|
45 | ||
46 | ||
47 | /** |
|
48 | * @return array |
|
49 | */ |
|
50 | protected function getOptions() |
|
51 | { |
|
52 | return [ |
|
53 | ['sql', false, InputOption::VALUE_NONE, 'Dumps SQL queries.'], |
|
54 | ]; |
|
55 | } |
|
56 | } |
|
57 |