Skip to content

Commit 0b74f72

Browse files
committed
Add extraOptions to dbDumper
1 parent a12430e commit 0b74f72

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/Commands/Create.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class Create extends Command
1111
{
12-
protected $signature = 'snapshot:create {name?} {--connection=} {--compress} {--table=*} {--exclude=*}';
12+
protected $signature = 'snapshot:create {name?} {--connection=} {--compress} {--table=*} {--exclude=*} {--extraOptions=*}';
1313

1414
protected $description = 'Create a new snapshot.';
1515

@@ -35,14 +35,18 @@ public function handle()
3535
$exclude = null;
3636
}
3737

38+
$extraOptions = $this->option('extraOptions') ?: config('db-snapshots.extraOptions', []);
39+
$extraOptions = is_string($extraOptions) ? explode(',', $exclude) : $exclude;
40+
3841

3942
$snapshot = app(SnapshotFactory::class)->create(
4043
$snapshotName,
4144
config('db-snapshots.disk'),
4245
$connectionName,
4346
$compress,
4447
$tables,
45-
$exclude
48+
$exclude,
49+
$extraOptions
4650
);
4751

4852
$size = Format::humanReadableSize($snapshot->size());

src/SnapshotFactory.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct(
2020
//
2121
}
2222

23-
public function create(string $snapshotName, string $diskName, string $connectionName, bool $compress = false, ?array $tables = null, ?array $exclude = null): Snapshot
23+
public function create(string $snapshotName, string $diskName, string $connectionName, bool $compress = false, ?array $tables = null, ?array $exclude = null, array $extraOptions = []): Snapshot
2424
{
2525
$disk = $this->getDisk($diskName);
2626

@@ -84,6 +84,10 @@ protected function createDump(string $connectionName, string $fileName, Filesyst
8484
$dbDumper->excludeTables($exclude);
8585
}
8686

87+
foreach ($extraOptions as $extraOption) {
88+
$dbDumper->addExtraOption($extraOption);
89+
}
90+
8791
$dbDumper->dumpToFile($dumpPath);
8892

8993
$file = fopen($dumpPath, 'r');

0 commit comments

Comments
 (0)