Skip to content

Commit

Permalink
add option to export only structure without data
Browse files Browse the repository at this point in the history
Signed-off-by: Dieter Coopman <dieter@deltasolutions.be>
  • Loading branch information
dietercoopman committed May 17, 2023
1 parent dfb3739 commit 6cd4581
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/MysqlBackupCommand.php
Expand Up @@ -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;
Expand All @@ -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']);
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 6cd4581

Please sign in to comment.