laravel/framework · error · RuntimeException
This database driver does not support the computed type.
Error message
This database driver does not support the computed type.
What it means
Base Grammar::typeComputed() throws RuntimeException because the driver's grammar does not support the 'computed' column type (generated columns: STORED/VIRTUAL). typeComputed is dispatched by getType() (Grammar.php:339) when a Blueprint declares $table->computed(...). Drivers that support generated columns override it (MySQL, Postgres, SQL Server); SQLite and others do not.
Source
Thrown at src/Illuminate/Database/Schema/Grammars/Grammar.php:352
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function getType(Fluent $column)
{
return $this->{'type'.ucfirst($column->type)}($column);
}
/**
* Create the column definition for a generated, computed column type.
*
* @param \Illuminate\Support\Fluent $column
* @return void
*
* @throws \RuntimeException
*/
protected function typeComputed(Fluent $column)
{
throw new RuntimeException('This database driver does not support the computed type.');
}
/**
* Create the column definition for a vector type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*
* @throws \RuntimeException
*/
protected function typeVector(Fluent $column)
{
throw new RuntimeException('This database driver does not support the vector type.');
}
/**
* Create the column definition for a tsvector type.
*View on GitHub (pinned to bd6b5437e6)
Solutions
- Use MySQL, Postgres, or SQL Server if you need generated columns.
- Remove the computed() column on unsupported drivers.
- Conditionally add the column only when the driver supports generated columns.
Example fix
// before
Schema::create('orders', function (Blueprint $t) {
$t->integer('qty');
$t->integer('price');
$t->computed('qty * price')->storedAs('total');
});
// after
$driver = DB::connection()->getDriverName();
Schema::create('orders', function (Blueprint $t) use ($driver) {
$t->integer('qty');
$t->integer('price');
if (in_array($driver, ['mysql','pgsql','sqlsrv'], true)) {
$t->computed('qty * price')->storedAs('total');
} else {
$t->integer('total')->default(0); // fallback
}
}); Defensive patterns
Strategy: validation
Validate before calling
$driver = DB::connection()->getDriverName();
if (! in_array($driver, ['mysql','pgsql','sqlsrv'], true)) {
return; // computed columns unsupported
}
Schema::create('orders', fn (Blueprint $t) => $t->computed('qty * price')->storedAs('total')); Type guard
function driverSupportsComputedColumns(): bool
{
return in_array(DB::connection()->getDriverName(), ['mysql','pgsql','sqlsrv'], true);
} Try / catch
try {
Schema::table('orders', fn (Blueprint $t) => $t->computed('qty * price')->storedAs('total'));
} catch (\RuntimeException $e) {
if (str_contains($e->getMessage(), 'computed type')) {
// fall back to a regular column or application-side computation
} else {
throw $e;
}
} Prevention
- Guard computed()/storedAs()/virtualAs() by driver.
- Align CI driver with production.
- Provide a fallback column or compute in app code on unsupported drivers.
When it happens
Trigger: Declaring $table->computed($expression) or any column whose ->type is 'computed' in a migration on a driver whose grammar does not override typeComputed.
Common situations: Cross-driver migration using computed/generated columns running against SQLite tests; CI defaulting to SQLite while app migrations use computed columns.
Related errors
- This database driver does not support the vector type.
- This database driver does not support retrieving columns.
- This database driver does not support modifying columns.
- This database driver does not support fulltext index creatio
- This database driver does not support fulltext index removal
AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06).
Data as JSON: /data/errors/5d0e3db95a1aef12.json.
Report an issue: GitHub.