diff --git a/src/Illuminate/Database/Console/DumpCommand.php b/src/Illuminate/Database/Console/DumpCommand.php index 49d80257aa10..bd5851fa5c6c 100644 --- a/src/Illuminate/Database/Console/DumpCommand.php +++ b/src/Illuminate/Database/Console/DumpCommand.php @@ -74,7 +74,7 @@ protected function schemaState(Connection $connection) $migrationTable = is_array($migrations) ? ($migrations['table'] ?? 'migrations') : $migrations; return $connection->getSchemaState() - ->withMigrationTable($connection->getTablePrefix().$migrationTable) + ->withMigrationTable($migrationTable) ->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 5bed2f003974..8c5607545a81 100644 --- a/src/Illuminate/Database/Schema/MySqlSchemaState.php +++ b/src/Illuminate/Database/Schema/MySqlSchemaState.php @@ -55,7 +55,7 @@ protected function removeAutoIncrementingState(string $path) protected function appendMigrationData(string $path) { $process = $this->executeDumpProcess($this->makeProcess( - $this->baseDumpCommand().' '.$this->migrationTable.' --no-create-info --skip-extended-insert --skip-routines --compact --complete-insert' + $this->baseDumpCommand().' '.$this->getMigrationTable().' --no-create-info --skip-extended-insert --skip-routines --compact --complete-insert' ), null, array_merge($this->baseVariables($this->connection->getConfig()), [ // ])); diff --git a/src/Illuminate/Database/Schema/PostgresBuilder.php b/src/Illuminate/Database/Schema/PostgresBuilder.php index be6512bbf2f7..c8d7cd4c8b4e 100755 --- a/src/Illuminate/Database/Schema/PostgresBuilder.php +++ b/src/Illuminate/Database/Schema/PostgresBuilder.php @@ -254,7 +254,7 @@ protected function getSchemas() * @param string $reference * @return array */ - protected function parseSchemaAndTable($reference) + public function parseSchemaAndTable($reference) { $parts = explode('.', $reference); diff --git a/src/Illuminate/Database/Schema/PostgresSchemaState.php b/src/Illuminate/Database/Schema/PostgresSchemaState.php index 70ccd25b5fd3..d6915706c3d0 100644 --- a/src/Illuminate/Database/Schema/PostgresSchemaState.php +++ b/src/Illuminate/Database/Schema/PostgresSchemaState.php @@ -20,7 +20,7 @@ public function dump(Connection $connection, $path) ]); if ($this->hasMigrationTable()) { - $commands->push($this->baseDumpCommand().' -t '.$this->migrationTable.' --data-only >> '.$path); + $commands->push($this->baseDumpCommand().' -t '.$this->getMigrationTable().' --data-only >> '.$path); } $commands->map(function ($command, $path) { @@ -51,6 +51,18 @@ public function load($path) ])); } + /** + * Get the name of the application's migration table. + * + * @return string + */ + protected function getMigrationTable(): string + { + [$schema, $table] = $this->connection->getSchemaBuilder()->parseSchemaAndTable($this->migrationTable); + + return $schema.'.'.$this->connection->getTablePrefix().$table; + } + /** * Get the base dump command arguments for PostgreSQL as a string. * diff --git a/src/Illuminate/Database/Schema/SchemaState.php b/src/Illuminate/Database/Schema/SchemaState.php index 2b2236af8801..d72085081487 100644 --- a/src/Illuminate/Database/Schema/SchemaState.php +++ b/src/Illuminate/Database/Schema/SchemaState.php @@ -104,6 +104,16 @@ public function hasMigrationTable(): bool return $this->connection->getSchemaBuilder()->hasTable($this->migrationTable); } + /** + * Get the name of the application's migration table. + * + * @return string + */ + protected function getMigrationTable(): string + { + return $this->connection->getTablePrefix().$this->migrationTable; + } + /** * Specify the name of the application's migration table. * diff --git a/src/Illuminate/Database/Schema/SqliteSchemaState.php b/src/Illuminate/Database/Schema/SqliteSchemaState.php index 4b66542923e4..07076fafa2c2 100644 --- a/src/Illuminate/Database/Schema/SqliteSchemaState.php +++ b/src/Illuminate/Database/Schema/SqliteSchemaState.php @@ -42,7 +42,7 @@ public function dump(Connection $connection, $path) protected function appendMigrationData(string $path) { with($process = $this->makeProcess( - $this->baseCommand().' ".dump \''.$this->migrationTable.'\'"' + $this->baseCommand().' ".dump \''.$this->getMigrationTable().'\'"' ))->mustRun(null, array_merge($this->baseVariables($this->connection->getConfig()), [ // ]));