laravel/framework · error · RuntimeException
This database driver requires a type, see the virtualAs / st
Error message
This database driver requires a type, see the virtualAs / storedAs modifiers.
What it means
MySQL's typeComputed() throws because MySQL has no standalone 'computed' SQL column type. Computed/virtual columns in MySQL are defined by attaching a virtualAs() or storedAs() expression to a real underlying type (e.g. INTEGER, VARCHAR). Throwing here signals that the developer asked for a computed column without specifying its base type.
Source
Thrown at src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php:1186
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeGeography(Fluent $column)
{
return $this->typeGeometry($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 requires a type, see the virtualAs / storedAs modifiers.');
}
/**
* Create the column definition for a vector type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeVector(Fluent $column)
{
return isset($column->dimensions) && $column->dimensions !== ''
? "vector({$column->dimensions})"
: 'vector';
}
/**
* Get the SQL for a generated virtual column modifier.
*View on GitHub (pinned to bd6b5437e6)
Solutions
- Replace $table->computed($expr) with a concrete base type plus the modifier: $table->string('col')->virtualAs($expr) (not persisted) or ->storedAs($expr) (persisted).
- If you only need a virtual expression, ensure the base type matches the expression's result type so MySQL can store/represent it.
- Switch the table to a driver that supports the computed type natively (sqlsrv) if you cannot rewrite the column.
Example fix
// before
$table->computed('full_name');
// after (MySQL)
$table->string('full_name')
->virtualAs('concat(first_name, " ", last_name)');
// or persisted:
$table->string('full_name')
->storedAs('concat(first_name, " ", last_name)'); Defensive patterns
Strategy: validation
Validate before calling
// Use a base type + modifier instead of the 'computed' pseudo-type // (validation is by construction: never call $table->computed() on MySQL)
Prevention
- On MySQL/MariaDB always pair a concrete type with virtualAs()/storedAs().
- Reserve $table->computed() for SQL Server.
- Lint migrations for bare computed() usage before deploying.
When it happens
Trigger: Calling $table->computed('full_name') directly on a MySQL/MariaDB connection. The correct shape is $table->string('full_name')->virtualAs('concat(first_name, last_name)') or ->storedAs(...). Using the bare 'computed' pseudo-type only works on SQL Server / Postgres.
Common situations: Porting a SQL Server migration (where 'computed' is valid) to MySQL; misunderstanding the API after reading cross-driver docs; auto-generated migrations from a tool that emits a generic computed type.
Related errors
- This database driver does not support the computed type.
- This database driver does not support modifying generated co
- This database driver requires a type, see the virtualAs / st
- This database driver does not support modifying columns.
- This database driver does not support fulltext index creatio
AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06).
Data as JSON: /data/errors/8f64d859efcfc9d4.json.
Report an issue: GitHub.