1 | <?php |
||
2 | |||
3 | namespace Bdf\Prime\Console; |
||
4 | |||
5 | use Bdf\Prime\Connection\ConnectionInterface; |
||
6 | use Symfony\Component\Console\Attribute\AsCommand; |
||
7 | use Symfony\Component\Console\Input\InputOption; |
||
8 | |||
9 | /** |
||
10 | * |
||
11 | */ |
||
12 | #[AsCommand('prime:database:drop', 'Drops the database from the configuration')] |
||
13 | class DropDatabaseCommand extends DatabaseCommand |
||
14 | { |
||
15 | protected static $defaultName = 'prime:database:drop'; |
||
16 | |||
17 | /** |
||
18 | * {@inheritdoc} |
||
19 | */ |
||
20 | protected function configure(): void |
||
21 | { |
||
22 | parent::configure(); |
||
23 | |||
24 | $this |
||
25 | ->setDescription('Drops the database from the configuration') |
||
26 | ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force the database deletion.') |
||
27 | ; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * {@inheritdoc} |
||
32 | */ |
||
33 | protected function interactWithDatabase(ConnectionInterface $connection, ?string $dbName): void |
||
34 | { |
||
35 | if ($this->io->option('force') || $this->io->confirm("Would you like to drop database <comment>$dbName</comment>?")) { |
||
36 | $connection->schema()->dropDatabase($dbName); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
37 | |||
38 | $this->io->line('Database <comment>%s</comment> has been <info>dropped</info> for connection <comment>%s</comment>.', $dbName, $connection->getName()); |
||
39 | } |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | protected function interactWithNoDatabase(ConnectionInterface $connection, ?string $dbName): void |
||
46 | { |
||
47 | $this->io->line('Database <comment>%s</comment> for connection <comment>%s</comment> does not exist.', $dbName, $connection->getName()); |
||
48 | } |
||
49 | } |
||
50 |