Implement mysqldump/backup service/command
This commit is contained in:
@ -2,19 +2,23 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Service\DatabaseManager;
|
||||
use App\Service\BackupService;
|
||||
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;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
|
||||
class BackupDatabase extends Command
|
||||
{
|
||||
protected static $defaultName = 'app:db:create';
|
||||
use SelectDatabaseQuestion;
|
||||
|
||||
protected static $defaultName = 'app:db:backup';
|
||||
|
||||
public function __construct(
|
||||
private DatabaseManager $db,
|
||||
private DatabaseService $db,
|
||||
private BackupService $bs,
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
@ -27,15 +31,10 @@ class BackupDatabase extends Command
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$question = $this->getHelper('question');
|
||||
$db = $this->getDatabaseName($input, $output);
|
||||
|
||||
if (!$name = $input->getArgument('name')) {
|
||||
$name = $question->ask($input, $output, new Question('Database name: '));
|
||||
}
|
||||
|
||||
$this->db->createDatabase($name);
|
||||
|
||||
$output->writeln(sprintf('Database "%s" successfully created', $name));
|
||||
$output = $this->bs->backup($db);
|
||||
dump($output);
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Service\DatabaseManager;
|
||||
use App\Service\DatabaseService;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
@ -14,7 +14,7 @@ class CreateDatabaseCommand extends Command
|
||||
protected static $defaultName = 'app:db:create';
|
||||
|
||||
public function __construct(
|
||||
private DatabaseManager $db,
|
||||
private DatabaseService $db,
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Service\DatabaseManager;
|
||||
use App\Service\DatabaseService;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@ -12,7 +12,7 @@ class ListDatabasesCommand extends Command
|
||||
protected static $defaultName = 'app:db:list';
|
||||
|
||||
public function __construct(
|
||||
private DatabaseManager $db,
|
||||
private DatabaseService $db,
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Service\DatabaseManager;
|
||||
use App\Service\DatabaseService;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@ -12,7 +12,7 @@ class ListUsersCommand extends Command
|
||||
protected static $defaultName = 'app:users:list';
|
||||
|
||||
public function __construct(
|
||||
private DatabaseManager $db,
|
||||
private DatabaseService $db,
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
|
Reference in New Issue
Block a user