From 6cd458112b695ac61879f814599643756388abc2 Mon Sep 17 00:00:00 2001 From: Dieter Coopman Date: Wed, 17 May 2023 16:35:26 +0200 Subject: [PATCH] add option to export only structure without data Signed-off-by: Dieter Coopman --- src/MysqlBackupCommand.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/MysqlBackupCommand.php b/src/MysqlBackupCommand.php index ea01931..d236d41 100644 --- a/src/MysqlBackupCommand.php +++ b/src/MysqlBackupCommand.php @@ -4,6 +4,7 @@ use DeltaSolutions\MysqlTools\Services\DatabaseManager; use DeltaSolutions\MysqlTools\Traits\HasServer; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; use function Termwind\render; @@ -21,7 +22,8 @@ protected function configure() { $this ->setName('mysql:backup') - ->setDescription('Get a structure and data backup from a database') + ->setDescription('Get a structure and data backup from a database ( add option --nodata if you only want the structure )') + ->addOption('nodata', null, InputOption::VALUE_OPTIONAL, 'Only create a structure backup for this database',false) ->setAliases(['mb']); } @@ -60,7 +62,10 @@ public function execute(InputInterface $input, OutputInterface $output): int $changes = $databaseManager->getFullSchema($sourceDatabase); $databaseManager->saveToFile($changes, $sourceDatabase, 'backup'); - $databaseManager->exportTables($sourceDatabase); + + if($input->getOption('nodata') === false) { + $databaseManager->exportTables($sourceDatabase); + } return 0; }