laravel/framework · error · RuntimeException

This database driver does not support retrieving indexes.

Error message

This database driver does not support retrieving indexes.

What it means

Base Grammar::compileIndexes() throws RuntimeException when the driver's grammar does not override it. It powers Schema::getIndexes(); all first-class drivers implement it, so this surfaces only for a custom/incomplete grammar.

Source

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

     * @throws \RuntimeException
     */
    public function compileColumns($schema, $table)
    {
        throw new RuntimeException('This database driver does not support retrieving columns.');
    }

    /**
     * Compile the query to determine the indexes.
     *
     * @param  string|null  $schema
     * @param  string  $table
     * @return string
     *
     * @throws \RuntimeException
     */
    public function compileIndexes($schema, $table)
    {
        throw new RuntimeException('This database driver does not support retrieving indexes.');
    }

    /**
     * Compile a vector index key command.
     *
     * @param  \Illuminate\Database\Schema\Blueprint  $blueprint
     * @param  \Illuminate\Support\Fluent  $command
     * @return void
     *
     * @throws \RuntimeException
     */
    public function compileVectorIndex(Blueprint $blueprint, Fluent $command)
    {
        throw new RuntimeException('The database driver in use does not support vector indexes.');
    }

    /**
     * Compile the query to determine the foreign keys.

View on GitHub (pinned to bd6b5437e6)

Solutions

  1. Use a first-class driver (mysql, pgsql, sqlite, sqlsrv).
  2. Implement compileIndexes($schema, $table) on your custom grammar.
  3. Verify the connection binding in config/database.php.

Example fix

// before
$indexes = Schema::connection('custom')->getIndexes('users');

// after — implement on custom grammar
public function compileIndexes($schema, $table)
{
    return 'select ... from information_schema.statistics ...';
}
Defensive patterns

Strategy: type-guard

Validate before calling

$grammar = Schema::getConnection()->getSchemaGrammar();
if ((new \ReflectionMethod($grammar, 'compileIndexes'))->getDeclaringClass()->getName()
    === \Illuminate\Database\Schema\Grammars\Grammar::class) {
    throw new \RuntimeException('Index listing unsupported on '.DB::connection()->getDriverName());
}
return Schema::getIndexes($table);

Type guard

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

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

Try / catch

try {
    $indexes = Schema::getIndexes($table);
} catch (\RuntimeException $e) {
    $indexes = [];
}

Prevention

When it happens

Trigger: Calling Schema::getIndexes($table) on a connection whose grammar lacks the override; introspection tooling running against a stub driver.

Common situations: Custom driver not implementing compileIndexes; outdated community driver behind the framework version.

Related errors


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