Skip to content

Commit

Permalink
respect migration table name in config when dumping schema
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Nov 5, 2020
1 parent 9561987 commit 110eb15
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Illuminate/Database/Console/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Schema/MySqlSchemaState.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()), [
//
]));
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Schema/PostgresSchemaState.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ');
Expand Down
20 changes: 20 additions & 0 deletions src/Illuminate/Database/Schema/SchemaState.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Schema/SqliteSchemaState.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()), [
//
]));
Expand Down

0 comments on commit 110eb15

Please sign in to comment.