1 | <?php |
||
2 | |||
3 | namespace Bdf\Prime\Console; |
||
4 | |||
5 | use Bdf\Prime\Connection\ConnectionInterface; |
||
6 | use Symfony\Component\Console\Attribute\AsCommand; |
||
7 | |||
8 | /** |
||
9 | * |
||
10 | */ |
||
11 | #[AsCommand('prime:database:create', 'Creates the database from the configuration')] |
||
12 | class CreateDatabaseCommand extends DatabaseCommand |
||
13 | { |
||
14 | protected static $defaultName = 'prime:database:create'; |
||
15 | |||
16 | /** |
||
17 | * {@inheritdoc} |
||
18 | */ |
||
19 | 1 | protected function configure(): void |
|
20 | { |
||
21 | 1 | parent::configure(); |
|
22 | |||
23 | 1 | $this |
|
24 | 1 | ->setDescription('Creates the database from the configuration') |
|
25 | 1 | ; |
|
26 | } |
||
27 | |||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | protected function interactWithDatabase(ConnectionInterface $connection, ?string $dbName): void |
||
32 | { |
||
33 | $this->io->line('Database <comment>%s</comment> for connection <comment>%s</comment> already exists.', $dbName, $connection->getName()); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | */ |
||
39 | protected function interactWithNoDatabase(ConnectionInterface $connection, ?string $dbName): void |
||
40 | { |
||
41 | $connection->schema()->createDatabase($dbName); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
42 | |||
43 | $this->io->line('Database <comment>%s</comment> has been <info>created</info> for connection <comment>%s</comment>.', $dbName, $connection->getName()); |
||
44 | } |
||
45 | } |
||
46 |