diff --git a/src/Illuminate/Database/Console/DumpCommand.php b/src/Illuminate/Database/Console/DumpCommand.php index 24e0fa91de8f..4cb26bde3c3b 100644 --- a/src/Illuminate/Database/Console/DumpCommand.php +++ b/src/Illuminate/Database/Console/DumpCommand.php @@ -8,6 +8,7 @@ use Illuminate\Database\ConnectionResolverInterface; use Illuminate\Database\Events\SchemaDumped; use Illuminate\Filesystem\Filesystem; +use Illuminate\Support\Facades\Config; class DumpCommand extends Command { @@ -63,6 +64,7 @@ public function handle(ConnectionResolverInterface $connections, Dispatcher $dis protected function schemaState(Connection $connection) { return $connection->getSchemaState() + ->withMigrationTable(Config::get('database.migrations', 'migrations')) ->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 eda6c886009a..472739f787ec 100644 --- a/src/Illuminate/Database/Schema/MySqlSchemaState.php +++ b/src/Illuminate/Database/Schema/MySqlSchemaState.php @@ -53,7 +53,7 @@ protected function removeAutoIncrementingState(string $path) protected function appendMigrationData(string $path) { $process = $this->executeDumpProcess($this->makeProcess( - $this->baseDumpCommand().' migrations --no-create-info --skip-extended-insert --skip-routines --compact' + $this->baseDumpCommand().' '.$this->migrationTable.' --no-create-info --skip-extended-insert --skip-routines --compact' ), null, array_merge($this->baseVariables($this->connection->getConfig()), [ // ])); diff --git a/src/Illuminate/Database/Schema/PostgresSchemaState.php b/src/Illuminate/Database/Schema/PostgresSchemaState.php index 8cfa45c21cfd..8349a0b53083 100644 --- a/src/Illuminate/Database/Schema/PostgresSchemaState.php +++ b/src/Illuminate/Database/Schema/PostgresSchemaState.php @@ -19,7 +19,7 @@ public function dump(Connection $connection, $path) $excludedTables = collect($connection->getSchemaBuilder()->getAllTables()) ->map->tablename ->reject(function ($table) { - return $table === 'migrations'; + return $table === $this->migrationTable; })->map(function ($table) { return '--exclude-table-data='.$table; })->implode(' '); diff --git a/src/Illuminate/Database/Schema/SchemaState.php b/src/Illuminate/Database/Schema/SchemaState.php index 781191e6fd43..6c4e56578252 100644 --- a/src/Illuminate/Database/Schema/SchemaState.php +++ b/src/Illuminate/Database/Schema/SchemaState.php @@ -22,6 +22,13 @@ abstract class SchemaState */ protected $files; + /** + * The name of the application's migration table. + * + * @var string + */ + protected $migrationTable = 'migrations'; + /** * The process factory callback. * @@ -87,6 +94,19 @@ public function makeProcess(...$arguments) return call_user_func($this->processFactory, ...$arguments); } + /** + * Specify the name of the application's migration table. + * + * @param string $table + * @return $this + */ + public function withMigrationTable(string $table) + { + $this->migrationTable = $table; + + return $this; + } + /** * Specify the callback that should be used to handle process output. * diff --git a/src/Illuminate/Database/Schema/SqliteSchemaState.php b/src/Illuminate/Database/Schema/SqliteSchemaState.php index 57187843e6a7..247b52a534fa 100644 --- a/src/Illuminate/Database/Schema/SqliteSchemaState.php +++ b/src/Illuminate/Database/Schema/SqliteSchemaState.php @@ -39,7 +39,7 @@ public function dump(Connection $connection, $path) protected function appendMigrationData(string $path) { with($process = $this->makeProcess( - $this->baseCommand().' ".dump \'migrations\'"' + $this->baseCommand().' ".dump \''.$this->migrationTable.'\'"' ))->mustRun(null, array_merge($this->baseVariables($this->connection->getConfig()), [ // ]));