Add delete and purge Command
This commit is contained in:
@ -17,8 +17,7 @@ class BackupDatabase extends Command
|
||||
protected static $defaultName = 'db:backup';
|
||||
|
||||
public function __construct(
|
||||
private DatabaseService $db,
|
||||
private BackupService $bs,
|
||||
private readonly BackupService $bs,
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
|
39
src/Console/DeleteDatabaseCommand.php
Normal file
39
src/Console/DeleteDatabaseCommand.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Service\DatabaseService;
|
||||
use App\Service\Traits\SelectDatabaseQuestion;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class DeleteDatabaseCommand extends Command
|
||||
{
|
||||
use SelectDatabaseQuestion;
|
||||
|
||||
protected static $defaultName = 'db:delete';
|
||||
|
||||
public function __construct(
|
||||
private DatabaseService $db,
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->addArgument('name', InputArgument::OPTIONAL, 'Database name');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$db = $this->getDatabaseName($input, $output);
|
||||
|
||||
$this->db->deleteDatabase($db);
|
||||
$output->writeln(sprintf('Database deleted: %s', $db));
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
39
src/Console/PurgeDatabaseCommand.php
Normal file
39
src/Console/PurgeDatabaseCommand.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Service\DatabaseService;
|
||||
use App\Service\Traits\SelectDatabaseQuestion;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class PurgeDatabaseCommand extends Command
|
||||
{
|
||||
use SelectDatabaseQuestion;
|
||||
|
||||
protected static $defaultName = 'db:purge';
|
||||
|
||||
public function __construct(
|
||||
private DatabaseService $db,
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->addArgument('name', InputArgument::OPTIONAL, 'Database name');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$db = $this->getDatabaseName($input, $output);
|
||||
|
||||
$this->db->purgeDatabase($db);
|
||||
$output->writeln(sprintf('Database purged: %s', $db));
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user