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
- Use pgsql if you need user-defined type enumeration.
- Remove or guard the Schema::getTypes() call on non-Postgres connections.
- 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
- Reserve getTypes() for Postgres.
- Guard by driver in cross-driver utilities.
- Return an empty list instead of crashing on unsupported drivers.
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
- This database driver does not support dropping all types.
- The database driver in use does not support vector indexes.
- This database driver does not support the vector type.
- Extensions are only supported by Postgres.
- This database driver does not support retrieving schemas.
AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06).
Data as JSON: /data/errors/306da6c812756d2e.json.
Report an issue: GitHub.