laravel/framework · error · RuntimeException

This database driver does not support retrieving user-define

Error message

This database driver does not support retrieving user-defined types.

What it means

Base Grammar::compileTypes() throws RuntimeException when the driver's grammar does not override it. User-defined types are primarily a Postgres feature (enums/composites), so PostgresGrammar overrides compileTypes; other drivers do not. It backs Schema::getTypes().

Source

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

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

    /**
     * Compile the query to determine the user-defined types.
     *
     * @param  string|string[]|null  $schema
     * @return string
     *
     * @throws \RuntimeException
     */
    public function compileTypes($schema)
    {
        throw new RuntimeException('This database driver does not support retrieving user-defined types.');
    }

    /**
     * Compile the query to determine the columns.
     *
     * @param  string|null  $schema
     * @param  string  $table
     * @return string
     *
     * @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.

View on GitHub (pinned to bd6b5437e6)

Solutions

  1. Use pgsql if you need user-defined type enumeration.
  2. Remove or guard the Schema::getTypes() call on non-Postgres connections.
  3. Return an empty list instead of calling the unsupported API.

Example fix

// before
$types = Schema::getTypes();

// after
$types = DB::connection()->getDriverName() === 'pgsql' ? Schema::getTypes() : [];
Defensive patterns

Strategy: type-guard

Validate before calling

if (DB::connection()->getDriverName() !== 'pgsql') {
    return [];
}
return Schema::getTypes();

Type guard

function driverSupportsTypeListing(): bool
{
    return DB::connection()->getDriverName() === 'pgsql';
}

Try / catch

try {
    $types = Schema::getTypes();
} catch (\RuntimeException $e) {
    $types = [];
}

Prevention

When it happens

Trigger: Calling Schema::getTypes() on a non-Postgres driver, or any code path that compiles a user-defined-type listing query against an unsupported grammar.

Common situations: Cross-driver introspection tools calling getTypes() on MySQL/SQLite; migrations that switch drivers but still enumerate types.

Related errors


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