From 93b0f6d26ee4cad5dcd61ce3ffc4556025f5abc5 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 5 Nov 2025 16:53:51 +0100 Subject: [PATCH 1/7] Add database dump with data --- .../Database/Console/DbDumpCommand.php | 82 +++++++++++++++++++ .../Database/Events/DatabaseDumped.php | 40 +++++++++ .../Database/Schema/MySqlSchemaState.php | 12 +-- .../Providers/ArtisanServiceProvider.php | 2 + 4 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 src/Illuminate/Database/Console/DbDumpCommand.php create mode 100644 src/Illuminate/Database/Events/DatabaseDumped.php diff --git a/src/Illuminate/Database/Console/DbDumpCommand.php b/src/Illuminate/Database/Console/DbDumpCommand.php new file mode 100644 index 000000000000..1f4d9f8d4a1c --- /dev/null +++ b/src/Illuminate/Database/Console/DbDumpCommand.php @@ -0,0 +1,82 @@ +connection($database = $this->input->getOption('database')); + + $this->schemaState($connection)->dump( + $connection, $path = $this->path($connection), true + ); + + $dispatcher->dispatch(new DatabaseDumped($connection, $path)); + + $info = 'Database dumped'; + + $this->components->info($info.' successfully to ' . $path); + } + + /** + * Create a schema state instance for the given connection. + * + * @param \Illuminate\Database\Connection $connection + * @return mixed + */ + protected function schemaState(Connection $connection) + { + return $connection->getSchemaState() + ->handleOutputUsing(function ($type, $buffer) { + $this->output->write($buffer); + }); + } + + /** + * Get the path that the dump should be written to. + * + * @param \Illuminate\Database\Connection $connection + */ + protected function path(Connection $connection) + { + return tap($this->option('path') ?: storage_path($connection->getName() . '-' . date("Ymdhis").'.sql'), function ($path) { + (new Filesystem)->ensureDirectoryExists(dirname($path)); + }); + } +} diff --git a/src/Illuminate/Database/Events/DatabaseDumped.php b/src/Illuminate/Database/Events/DatabaseDumped.php new file mode 100644 index 000000000000..7dd6c0780e41 --- /dev/null +++ b/src/Illuminate/Database/Events/DatabaseDumped.php @@ -0,0 +1,40 @@ +connection = $connection; + $this->connectionName = $connection->getName(); + $this->path = $path; + } +} diff --git a/src/Illuminate/Database/Schema/MySqlSchemaState.php b/src/Illuminate/Database/Schema/MySqlSchemaState.php index 427c943ff736..faa7f848e152 100644 --- a/src/Illuminate/Database/Schema/MySqlSchemaState.php +++ b/src/Illuminate/Database/Schema/MySqlSchemaState.php @@ -16,18 +16,20 @@ class MySqlSchemaState extends SchemaState * @param string $path * @return void */ - public function dump(Connection $connection, $path) + public function dump(Connection $connection, $path, $withData = false) { $this->executeDumpProcess($this->makeProcess( - $this->baseDumpCommand().' --routines --result-file="${:LARAVEL_LOAD_PATH}" --no-data' + $this->baseDumpCommand().' --routines --result-file="${:LARAVEL_LOAD_PATH}" ' . ($withData ? '' : '--no-data') ), $this->output, array_merge($this->baseVariables($this->connection->getConfig()), [ 'LARAVEL_LOAD_PATH' => $path, ])); - $this->removeAutoIncrementingState($path); + if (!$withData) { + $this->removeAutoIncrementingState($path); - if ($this->hasMigrationTable()) { - $this->appendMigrationData($path); + if ($this->hasMigrationTable()) { + $this->appendMigrationData($path); + } } } diff --git a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php index d2ae86019342..37d7494b0e8a 100755 --- a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php +++ b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php @@ -18,6 +18,7 @@ use Illuminate\Console\Signals; use Illuminate\Contracts\Support\DeferrableProvider; use Illuminate\Database\Console\DbCommand; +use Illuminate\Database\Console\DbDumpCommand; use Illuminate\Database\Console\DumpCommand; use Illuminate\Database\Console\Factories\FactoryMakeCommand; use Illuminate\Database\Console\MonitorCommand as DatabaseMonitorCommand; @@ -126,6 +127,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'ConfigClear' => ConfigClearCommand::class, 'ConfigShow' => ConfigShowCommand::class, 'Db' => DbCommand::class, + 'DbDump' => DbDumpCommand::class, 'DbMonitor' => DatabaseMonitorCommand::class, 'DbPrune' => PruneCommand::class, 'DbShow' => ShowCommand::class, From d83baac486efa34ba0f0240576e6e91c4d7ce628 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 19 Nov 2025 13:53:33 +0100 Subject: [PATCH 2/7] Tweak withData state --- .../Database/Console/DbDumpCommand.php | 3 +- .../Database/Schema/MySqlSchemaState.php | 15 ++++++---- .../Database/Schema/SchemaState.php | 30 +++++++++++++++++++ 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/Illuminate/Database/Console/DbDumpCommand.php b/src/Illuminate/Database/Console/DbDumpCommand.php index 1f4d9f8d4a1c..3189bb3c7463 100644 --- a/src/Illuminate/Database/Console/DbDumpCommand.php +++ b/src/Illuminate/Database/Console/DbDumpCommand.php @@ -44,7 +44,7 @@ public function handle(ConnectionResolverInterface $connections, Dispatcher $dis $connection = $connections->connection($database = $this->input->getOption('database')); $this->schemaState($connection)->dump( - $connection, $path = $this->path($connection), true + $connection, $path = $this->path($connection) ); $dispatcher->dispatch(new DatabaseDumped($connection, $path)); @@ -63,6 +63,7 @@ public function handle(ConnectionResolverInterface $connections, Dispatcher $dis protected function schemaState(Connection $connection) { return $connection->getSchemaState() + ->withData() ->handleOutputUsing(function ($type, $buffer) { $this->output->write($buffer); }); diff --git a/src/Illuminate/Database/Schema/MySqlSchemaState.php b/src/Illuminate/Database/Schema/MySqlSchemaState.php index faa7f848e152..a9ba45e891b7 100644 --- a/src/Illuminate/Database/Schema/MySqlSchemaState.php +++ b/src/Illuminate/Database/Schema/MySqlSchemaState.php @@ -16,15 +16,20 @@ class MySqlSchemaState extends SchemaState * @param string $path * @return void */ - public function dump(Connection $connection, $path, $withData = false) + public function dump(Connection $connection, $path) { - $this->executeDumpProcess($this->makeProcess( - $this->baseDumpCommand().' --routines --result-file="${:LARAVEL_LOAD_PATH}" ' . ($withData ? '' : '--no-data') - ), $this->output, array_merge($this->baseVariables($this->connection->getConfig()), [ + $dumpCommand = $this->baseDumpCommand().' --routines --result-file="${:LARAVEL_LOAD_PATH}"'; + + if ($this->hasData()) { + $dumpCommand .= ' --single-transaction --quick'; + } else { + $dumpCommand .= ' --no-data'; + } + $this->executeDumpProcess($this->makeProcess($dumpCommand), $this->output, array_merge($this->baseVariables($this->connection->getConfig()), [ 'LARAVEL_LOAD_PATH' => $path, ])); - if (!$withData) { + if (!$this->hasData()) { $this->removeAutoIncrementingState($path); if ($this->hasMigrationTable()) { diff --git a/src/Illuminate/Database/Schema/SchemaState.php b/src/Illuminate/Database/Schema/SchemaState.php index be792138f7b4..e54833ec1118 100644 --- a/src/Illuminate/Database/Schema/SchemaState.php +++ b/src/Illuminate/Database/Schema/SchemaState.php @@ -29,6 +29,13 @@ abstract class SchemaState */ protected $migrationTable = 'migrations'; + /** + * Indicates if the dumper should include data. + * + * @var bool + */ + protected $data = false; + /** * The process factory callback. * @@ -126,6 +133,29 @@ public function withMigrationTable(string $table) return $this; } + /** + * Check if the dumper should include data. + * + * @return bool + */ + public function hasData() + { + return $this->data; + } + + /** + * Indicate that the dumper should include data. + * + * @param bool $data + * @return $this + */ + public function withData(bool $data = true) + { + $this->data = $data; + + return $this; + } + /** * Specify the callback that should be used to handle process output. * From da04de0711aa441d57d4f0d21e0875596f807e3a Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 19 Nov 2025 14:18:10 +0100 Subject: [PATCH 3/7] Add sqlite --- .../Database/Schema/SqliteSchemaState.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Database/Schema/SqliteSchemaState.php b/src/Illuminate/Database/Schema/SqliteSchemaState.php index 3d954a39de17..8f1b719eedf6 100644 --- a/src/Illuminate/Database/Schema/SqliteSchemaState.php +++ b/src/Illuminate/Database/Schema/SqliteSchemaState.php @@ -16,18 +16,25 @@ class SqliteSchemaState extends SchemaState */ public function dump(Connection $connection, $path) { - $process = $this->makeProcess($this->baseCommand().' ".schema --indent"') + if ($this->hasData()) { + $dumpCommand = $this->baseCommand().' -batch ".dump"'; + } else { + $dumpCommand = $this->baseCommand().' ".schema --indent"'; + } + $process = $this->makeProcess($dumpCommand) ->setTimeout(null) ->mustRun(null, array_merge($this->baseVariables($this->connection->getConfig()), [ // ])); - $migrations = preg_replace('/CREATE TABLE sqlite_.+?\);[\r\n]+/is', '', $process->getOutput()); + if (!$this->hasData()) { + $migrations = preg_replace('/CREATE TABLE sqlite_.+?\);[\r\n]+/is', '', $process->getOutput()); - $this->files->put($path, $migrations.PHP_EOL); + $this->files->put($path, $migrations.PHP_EOL); - if ($this->hasMigrationTable()) { - $this->appendMigrationData($path); + if ($this->hasMigrationTable()) { + $this->appendMigrationData($path); + } } } From 8be622dfaa95a3b1d0940b31105a5133873e6222 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 19 Nov 2025 14:18:14 +0100 Subject: [PATCH 4/7] Add load command --- .../Database/Console/DbLoadCommand.php | 69 +++++++++++++++++++ .../Providers/ArtisanServiceProvider.php | 2 + 2 files changed, 71 insertions(+) create mode 100644 src/Illuminate/Database/Console/DbLoadCommand.php diff --git a/src/Illuminate/Database/Console/DbLoadCommand.php b/src/Illuminate/Database/Console/DbLoadCommand.php new file mode 100644 index 000000000000..cf9a477b1cb7 --- /dev/null +++ b/src/Illuminate/Database/Console/DbLoadCommand.php @@ -0,0 +1,69 @@ +connection($database = $this->input->getOption('database')); + + $path = $this->input->getOption('path') ?: $this->ask('Path to the schema dump file'); + $this->schemaState($connection)->load($path); + + $dispatcher->dispatch(new DatabaseDumped($connection, $path)); + + $info = 'Database loaded'; + + $this->components->info($info.' successfully in database ' . $database); + } + + /** + * Create a schema state instance for the given connection. + * + * @param \Illuminate\Database\Connection $connection + * @return mixed + */ + protected function schemaState(Connection $connection) + { + return $connection->getSchemaState() + ->handleOutputUsing(function ($type, $buffer) { + $this->output->write($buffer); + }); + } +} diff --git a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php index 37d7494b0e8a..a96d23530166 100755 --- a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php +++ b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php @@ -19,6 +19,7 @@ use Illuminate\Contracts\Support\DeferrableProvider; use Illuminate\Database\Console\DbCommand; use Illuminate\Database\Console\DbDumpCommand; +use Illuminate\Database\Console\DbLoadCommand; use Illuminate\Database\Console\DumpCommand; use Illuminate\Database\Console\Factories\FactoryMakeCommand; use Illuminate\Database\Console\MonitorCommand as DatabaseMonitorCommand; @@ -128,6 +129,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'ConfigShow' => ConfigShowCommand::class, 'Db' => DbCommand::class, 'DbDump' => DbDumpCommand::class, + 'DbLoad' => DbLoadCommand::class, 'DbMonitor' => DatabaseMonitorCommand::class, 'DbPrune' => PruneCommand::class, 'DbShow' => ShowCommand::class, From 6e23e07bbfe94f0f3b9bee1ff6e0063663a496cf Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 19 Nov 2025 14:38:12 +0100 Subject: [PATCH 5/7] TWeak load command --- .../Database/Console/DbLoadCommand.php | 29 +++++++++++--- .../Database/Events/DatabaseLoaded.php | 40 +++++++++++++++++++ .../Database/Schema/SqliteSchemaState.php | 2 + 3 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 src/Illuminate/Database/Events/DatabaseLoaded.php diff --git a/src/Illuminate/Database/Console/DbLoadCommand.php b/src/Illuminate/Database/Console/DbLoadCommand.php index cf9a477b1cb7..39ada86d3bf8 100644 --- a/src/Illuminate/Database/Console/DbLoadCommand.php +++ b/src/Illuminate/Database/Console/DbLoadCommand.php @@ -3,12 +3,13 @@ namespace Illuminate\Database\Console; use Illuminate\Console\Command; +use Illuminate\Console\ConfirmableTrait; +use Illuminate\Console\Prohibitable; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Connection; use Illuminate\Database\ConnectionResolverInterface; -use Illuminate\Database\Events\DatabaseDumped; +use Illuminate\Database\Events\DatabaseLoaded; use Illuminate\Database\Events\MigrationsPruned; -use Illuminate\Database\Events\SchemaDumped; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Facades\Config; use Symfony\Component\Console\Attribute\AsCommand; @@ -16,14 +17,17 @@ #[AsCommand(name: 'db:load')] class DbLoadCommand extends Command { + use ConfirmableTrait, Prohibitable; + /** * The console command name. * * @var string */ - protected $signature = 'db:load + protected $signature = 'db:load {path} {--database= : The database connection to use} - {--path= : The path where the schema dump file is stored}'; + {--force : Force the operation to run when in production} + {--drop : Drop the database before loading the dump}'; /** * The console command description. @@ -41,12 +45,25 @@ class DbLoadCommand extends Command */ public function handle(ConnectionResolverInterface $connections, Dispatcher $dispatcher) { + if ($this->isProhibited() || + ! $this->confirmToProceed()) { + return Command::FAILURE; + } + $connection = $connections->connection($database = $this->input->getOption('database')); - $path = $this->input->getOption('path') ?: $this->ask('Path to the schema dump file'); + $path = $this->argument('path'); + + if ($this->input->getOption('drop')) { + $this->call('db:wipe', array_filter([ + '--database' => $database, + '--force' => true, + ])); + } + $this->schemaState($connection)->load($path); - $dispatcher->dispatch(new DatabaseDumped($connection, $path)); + $dispatcher->dispatch(new DatabaseLoaded($connection, $path)); $info = 'Database loaded'; diff --git a/src/Illuminate/Database/Events/DatabaseLoaded.php b/src/Illuminate/Database/Events/DatabaseLoaded.php new file mode 100644 index 000000000000..e9d7be9ad248 --- /dev/null +++ b/src/Illuminate/Database/Events/DatabaseLoaded.php @@ -0,0 +1,40 @@ +connection = $connection; + $this->connectionName = $connection->getName(); + $this->path = $path; + } +} diff --git a/src/Illuminate/Database/Schema/SqliteSchemaState.php b/src/Illuminate/Database/Schema/SqliteSchemaState.php index 8f1b719eedf6..6fcdbed8e49f 100644 --- a/src/Illuminate/Database/Schema/SqliteSchemaState.php +++ b/src/Illuminate/Database/Schema/SqliteSchemaState.php @@ -35,6 +35,8 @@ public function dump(Connection $connection, $path) if ($this->hasMigrationTable()) { $this->appendMigrationData($path); } + } else { + $this->files->put($path, $process->getOutput()); } } From f2f92bee0e1943bcd222197c7ffeb61ab13b4eee Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 19 Nov 2025 14:54:58 +0100 Subject: [PATCH 6/7] CS fix --- src/Illuminate/Database/Console/DbDumpCommand.php | 7 ++----- src/Illuminate/Database/Console/DbLoadCommand.php | 5 +---- src/Illuminate/Database/Schema/MySqlSchemaState.php | 2 +- src/Illuminate/Database/Schema/SchemaState.php | 2 +- src/Illuminate/Database/Schema/SqliteSchemaState.php | 2 +- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Illuminate/Database/Console/DbDumpCommand.php b/src/Illuminate/Database/Console/DbDumpCommand.php index 3189bb3c7463..fb5367ad5188 100644 --- a/src/Illuminate/Database/Console/DbDumpCommand.php +++ b/src/Illuminate/Database/Console/DbDumpCommand.php @@ -7,10 +7,7 @@ use Illuminate\Database\Connection; use Illuminate\Database\ConnectionResolverInterface; use Illuminate\Database\Events\DatabaseDumped; -use Illuminate\Database\Events\MigrationsPruned; -use Illuminate\Database\Events\SchemaDumped; use Illuminate\Filesystem\Filesystem; -use Illuminate\Support\Facades\Config; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'db:dump')] @@ -51,7 +48,7 @@ public function handle(ConnectionResolverInterface $connections, Dispatcher $dis $info = 'Database dumped'; - $this->components->info($info.' successfully to ' . $path); + $this->components->info($info.' successfully to '.$path); } /** @@ -76,7 +73,7 @@ protected function schemaState(Connection $connection) */ protected function path(Connection $connection) { - return tap($this->option('path') ?: storage_path($connection->getName() . '-' . date("Ymdhis").'.sql'), function ($path) { + return tap($this->option('path') ?: storage_path($connection->getName().'-'.date("Ymdhis").'.sql'), function ($path) { (new Filesystem)->ensureDirectoryExists(dirname($path)); }); } diff --git a/src/Illuminate/Database/Console/DbLoadCommand.php b/src/Illuminate/Database/Console/DbLoadCommand.php index 39ada86d3bf8..0d3a1eed4deb 100644 --- a/src/Illuminate/Database/Console/DbLoadCommand.php +++ b/src/Illuminate/Database/Console/DbLoadCommand.php @@ -9,9 +9,6 @@ use Illuminate\Database\Connection; use Illuminate\Database\ConnectionResolverInterface; use Illuminate\Database\Events\DatabaseLoaded; -use Illuminate\Database\Events\MigrationsPruned; -use Illuminate\Filesystem\Filesystem; -use Illuminate\Support\Facades\Config; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'db:load')] @@ -67,7 +64,7 @@ public function handle(ConnectionResolverInterface $connections, Dispatcher $dis $info = 'Database loaded'; - $this->components->info($info.' successfully in database ' . $database); + $this->components->info($info.' successfully in database '.$database); } /** diff --git a/src/Illuminate/Database/Schema/MySqlSchemaState.php b/src/Illuminate/Database/Schema/MySqlSchemaState.php index a9ba45e891b7..d1eaa7596000 100644 --- a/src/Illuminate/Database/Schema/MySqlSchemaState.php +++ b/src/Illuminate/Database/Schema/MySqlSchemaState.php @@ -29,7 +29,7 @@ public function dump(Connection $connection, $path) 'LARAVEL_LOAD_PATH' => $path, ])); - if (!$this->hasData()) { + if (! $this->hasData()) { $this->removeAutoIncrementingState($path); if ($this->hasMigrationTable()) { diff --git a/src/Illuminate/Database/Schema/SchemaState.php b/src/Illuminate/Database/Schema/SchemaState.php index e54833ec1118..8373bb8ccbfd 100644 --- a/src/Illuminate/Database/Schema/SchemaState.php +++ b/src/Illuminate/Database/Schema/SchemaState.php @@ -146,7 +146,7 @@ public function hasData() /** * Indicate that the dumper should include data. * - * @param bool $data + * @param bool $data * @return $this */ public function withData(bool $data = true) diff --git a/src/Illuminate/Database/Schema/SqliteSchemaState.php b/src/Illuminate/Database/Schema/SqliteSchemaState.php index 6fcdbed8e49f..19caaccfc850 100644 --- a/src/Illuminate/Database/Schema/SqliteSchemaState.php +++ b/src/Illuminate/Database/Schema/SqliteSchemaState.php @@ -27,7 +27,7 @@ public function dump(Connection $connection, $path) // ])); - if (!$this->hasData()) { + if (! $this->hasData()) { $migrations = preg_replace('/CREATE TABLE sqlite_.+?\);[\r\n]+/is', '', $process->getOutput()); $this->files->put($path, $migrations.PHP_EOL); From b388c05380231a61e6443002056cf5e7f6a8bf21 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 19 Nov 2025 15:25:28 +0100 Subject: [PATCH 7/7] Add postgres --- src/Illuminate/Database/Console/DbDumpCommand.php | 2 +- src/Illuminate/Database/Console/DbLoadCommand.php | 2 +- .../Database/Schema/PostgresSchemaState.php | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Database/Console/DbDumpCommand.php b/src/Illuminate/Database/Console/DbDumpCommand.php index fb5367ad5188..07753946fa28 100644 --- a/src/Illuminate/Database/Console/DbDumpCommand.php +++ b/src/Illuminate/Database/Console/DbDumpCommand.php @@ -73,7 +73,7 @@ protected function schemaState(Connection $connection) */ protected function path(Connection $connection) { - return tap($this->option('path') ?: storage_path($connection->getName().'-'.date("Ymdhis").'.sql'), function ($path) { + return tap($this->option('path') ?: storage_path($connection->getName().'-'.date('Ymdhis').'.sql'), function ($path) { (new Filesystem)->ensureDirectoryExists(dirname($path)); }); } diff --git a/src/Illuminate/Database/Console/DbLoadCommand.php b/src/Illuminate/Database/Console/DbLoadCommand.php index 0d3a1eed4deb..718ae977a82f 100644 --- a/src/Illuminate/Database/Console/DbLoadCommand.php +++ b/src/Illuminate/Database/Console/DbLoadCommand.php @@ -64,7 +64,7 @@ public function handle(ConnectionResolverInterface $connections, Dispatcher $dis $info = 'Database loaded'; - $this->components->info($info.' successfully in database '.$database); + $this->components->info($info.' successfully in database '.$connection->getDatabaseName()); } /** diff --git a/src/Illuminate/Database/Schema/PostgresSchemaState.php b/src/Illuminate/Database/Schema/PostgresSchemaState.php index 25da812e61c5..375135a521cd 100644 --- a/src/Illuminate/Database/Schema/PostgresSchemaState.php +++ b/src/Illuminate/Database/Schema/PostgresSchemaState.php @@ -16,11 +16,18 @@ class PostgresSchemaState extends SchemaState */ public function dump(Connection $connection, $path) { + $dumpCommand = $this->baseDumpCommand(); + if ($this->hasData()) { + $dumpCommand .= ' --column-inserts'; + } else { + $dumpCommand .= ' ---schema-only'; + } + $commands = new Collection([ - $this->baseDumpCommand().' --schema-only > '.$path, + $dumpCommand.' > '.$path, ]); - if ($this->hasMigrationTable()) { + if (! $this->hasData() && $this->hasMigrationTable()) { $commands->push($this->baseDumpCommand().' -t '.$this->getMigrationTable().' --data-only >> '.$path); }