laravel/framework · error · RuntimeException
Extensions are only supported by Postgres.
Error message
Extensions are only supported by Postgres.
What it means
Builder::ensureExtensionExists() hard-checks that the connection is a PostgresConnection and throws RuntimeException otherwise, because CREATE EXTENSION is a Postgres-only DDL. ensureVectorExtensionExists() delegates here, so it inherits the same restriction. The guard is an explicit instanceof - no fallback, no no-op.
Solutions
- Gate the call on the connection driver: if (Schema::getConnection() instanceof \Illuminate\Database\PostgresConnection).
- Move ensureExtensionExists / ensureVectorExtensionExists calls into a Postgres-only migration or a service provider branch keyed on config('database.default').
- In tests, skip these migrations on SQLite or stub them out via a testing-specific migration path.
Example fix
// before
Schema::ensureVectorExtensionExists();
// after
use Illuminate\Database\PostgresConnection;
if (Schema::getConnection() instanceof PostgresConnection) {
Schema::ensureVectorExtensionExists();
} Defensive patterns
Strategy: type-guard
Validate before calling
use Illuminate\Database\PostgresConnection;
$connection = Schema::getConnection();
if ($connection instanceof PostgresConnection) {
Schema::ensureVectorExtensionExists();
} else {
throw new \DomainException('Vector extensions require a Postgres connection.');
} Type guard
use Illuminate\Database\PostgresConnection;
function isPostgres(\Illuminate\Database\Connection $connection): bool
{
return $connection instanceof PostgresConnection;
} Try / catch
try {
Schema::ensureExtensionExists('vector');
} catch (\RuntimeException $e) {
if (str_contains($e->getMessage(), 'only supported by Postgres')) {
return; // skip on non-Postgres connections
}
throw $e;
} Prevention
- Centralise extension setup in a Postgres-only service provider or migration.
- Make the testing connection Postgres-compatible or skip extension migrations in test env.
- Guard any code path inherited from a Postgres codebase when porting to a new engine.
When it happens
Trigger: Calling Schema::ensureExtensionExists($name, $schema) or Schema::ensureVectorExtensionExists($schema) on any non-Postgres connection (mysql, sqlite, sqlsrv, or a custom driver whose Connection class is not Illuminate\Database\PostgresConnection).
Common situations: A migration that unconditionally calls ensureVectorExtensionExists() but is run against the testing suite's SQLite connection; an app migrated from Postgres to MySQL where the extension bootstrap was left in place; a multi-database app that runs the same migration set on every connection.
Related errors
- The database driver in use does not support vector indexes.
- This database driver does not support fulltext index…
- This database driver does not support retrieving…
- This database driver does not support the computed type.
- This database driver does not support the vector type.
AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11).
Data as JSON: /api/errors/f711cb714cf9bf3a.
Report an issue: GitHub.
Appendix: source
Thrown at src/Illuminate/Database/Schema/Builder.php:683
*/
public function ensureVectorExtensionExists($schema = null)
{
$this->ensureExtensionExists('vector', $schema);
}
/**
* Create a new extension on the schema if it does not exist.
*
* @param string $name
* @param string|null $schema
* @return void
*
* @throws \RuntimeException
*/
public function ensureExtensionExists($name, $schema = null)
{
if (! $this->getConnection() instanceof PostgresConnection) {
throw new RuntimeException('Extensions are only supported by Postgres.');
}
$name = $this->getConnection()->getSchemaGrammar()->wrap($name);
$this->getConnection()->statement(match (filled($schema)) {
true => "create extension if not exists {$name} schema {$this->getConnection()->getSchemaGrammar()->wrap($schema)}",
false => "create extension if not exists {$name}",
});
}
/**
* Execute the blueprint to build / modify the table.
*
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @return void
*/
protected function build(Blueprint $blueprint)
{View on GitHub (pinned to e0f6eb3518)