laravel/framework · error · RuntimeException

This database driver does not support retrieving schemas.

Error message

This database driver does not support retrieving schemas.

What it means

Base Grammar::compileSchemas() throws RuntimeException because the driver's grammar does not override it. compileSchemas builds the information-schema query that backs Schema::getSchemas(); only drivers whose grammar overrides it (notably SQL Server) can list schemas. It signals a feature not implemented for this driver.

Source

Thrown at src/Illuminate/Database/Schema/Grammars/Grammar.php:75

     * @return string
     */
    public function compileDropDatabaseIfExists($name)
    {
        return sprintf('drop database if exists %s',
            $this->wrapValue($name)
        );
    }

    /**
     * Compile the query to determine the schemas.
     *
     * @return string
     *
     * @throws \RuntimeException
     */
    public function compileSchemas()
    {
        throw new RuntimeException('This database driver does not support retrieving schemas.');
    }

    /**
     * Compile the query to determine if the given table exists.
     *
     * @param  string|null  $schema
     * @param  string  $table
     * @return string|null
     */
    public function compileTableExists($schema, $table)
    {
        //
    }

    /**
     * Compile the query to determine the tables.
     *
     * @param  string|string[]|null  $schema

View on GitHub (pinned to bd6b5437e6)

Solutions

  1. Use a driver whose grammar overrides compileSchemas (e.g. sqlsrv).
  2. Avoid Schema::getSchemas() on unsupported drivers; fall back to a manual query against the engine's catalogue.
  3. Guard the call by checking the connection/grammar type before invoking.

Example fix

// before
$schemas = Schema::getSchemas();

// after
if (method_exists(Schema::getConnection()->getSchemaGrammar(), 'compileSchemas')
    && (new \ReflectionMethod(Schema::getConnection()->getSchemaGrammar(), 'compileSchemas'))->getDeclaringClass()->getName()
        !== \Illuminate\Database\Schema\Grammars\Grammar::class) {
    $schemas = Schema::getSchemas();
} else {
    $schemas = null; // unsupported on this driver
}
Defensive patterns

Strategy: type-guard

Validate before calling

$grammar = Schema::getConnection()->getSchemaGrammar();
if ((new \ReflectionMethod($grammar, 'compileSchemas'))->getDeclaringClass()->getName()
    === \Illuminate\Database\Schema\Grammars\Grammar::class) {
    return null; // unsupported
}
return Schema::getSchemas();

Type guard

function driverSupportsSchemaListing(): bool
{
    $g = Schema::getConnection()->getSchemaGrammar();

    return (new \ReflectionMethod($g, 'compileSchemas'))
        ->getDeclaringClass()->getName() !== \Illuminate\Database\Schema\Grammars\Grammar::class;
}

Try / catch

try {
    $schemas = Schema::getSchemas();
} catch (\RuntimeException $e) {
    $schemas = null; // unsupported driver
}

Prevention

When it happens

Trigger: Calling Schema::getSchemas() (or any path that calls Builder::getSchemas -> Grammar::compileSchemas) on a driver whose grammar lacks the override.

Common situations: Using getSchemas() with SQLite or MySQL where schema listing is unsupported; cross-driver code that assumed all drivers enumerate schemas.

Related errors


AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06). Data as JSON: /data/errors/5e3c80fa29381142.json. Report an issue: GitHub.