laravel/framework · error · RuntimeException
Schema dumping is not supported when using SQL Server.
Error message
Schema dumping is not supported when using SQL Server.
What it means
SqlServerConnection::getSchemaState overrides the base connection and unconditionally throws RuntimeException. Laravel ships no SqlServerSchemaState implementation, so schema:dump and the structure-migration tooling that depends on getSchemaState() cannot operate on a SQL Server connection. The intent is to fail loudly rather than emit a partial or incorrect dump.
Solutions
- Do not invoke schema:dump against SQL Server; remove it from your migration/CI workflow for the sqlsrv connection.
- Use SQL Server's own tooling (sqlpackage / generate-scripts in SSMS) to capture schema, then commit the .sql file and load it via migrations or a custom command.
- If you need parallel schema-state hooks, branch the command by driver and only call schema:dump for connections that support it.
Example fix
// before (always dumps, fails on sqlsrv)
Artisan::call('schema:dump');
// after (driver-guarded)
use Illuminate\Support\Facades\DB;
if (DB::connection()->getDriverName() !== 'sqlsrv') {
Artisan::call('schema:dump');
} Defensive patterns
Strategy: validation
Validate before calling
use Illuminate\Support\Facades\DB;
if (DB::connection()->getDriverName() !== 'sqlsrv') {
Artisan::call('schema:dump');
} Type guard
function supportsSchemaState(?\Illuminate\Database\ConnectionInterface $c = null): bool {
$c ??= \Illuminate\Support\Facades\DB::connection();
return ! $c instanceof \Illuminate\Database\SqlServerConnection;
} Prevention
- Exclude SQL Server connections from schema:dump workflows.
- Use sqlpackage / SSMS scripts for SQL Server schema capture.
- Branch schema tooling by driver in shared artisan commands.
When it happens
Trigger: Running php artisan schema:dump (or any code path that calls $connection->getSchemaState()) while the default DB connection (or the one targeted by the command) uses the 'sqlsrv' driver.
Common situations: Mixing SQL Server with the migrate:fresh --seed workflow that auto-dumps schema; CI pipelines that run schema:dump against every configured connection; copying a workflow from a MySQL project into a SQL Server project.
Related errors
- A class already exists.
- Database was not created. Aborting migration.
- Dump execution exceeded maximum depth of 30.
- Invalid database connection
- Method [run] missing from '.get_class($this)
AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11).
Data as JSON: /api/errors/d3067d8d23cd50d1.
Report an issue: GitHub.
Appendix: source
Thrown at src/Illuminate/Database/SqlServerConnection.php:154
*
* @return \Illuminate\Database\Schema\Grammars\SqlServerGrammar
*/
protected function getDefaultSchemaGrammar()
{
return new SchemaGrammar($this);
}
/**
* Get the schema state for the connection.
*
* @param \Illuminate\Filesystem\Filesystem|null $files
* @param callable|null $processFactory
*
* @throws \RuntimeException
*/
public function getSchemaState(?Filesystem $files = null, ?callable $processFactory = null)
{
throw new RuntimeException('Schema dumping is not supported when using SQL Server.');
}
/**
* Get the default post processor instance.
*
* @return \Illuminate\Database\Query\Processors\SqlServerProcessor
*/
protected function getDefaultPostProcessor()
{
return new SqlServerProcessor;
}
}
View on GitHub (pinned to e0f6eb3518)