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
SQLite's typeComputed() throws because, like MySQL, SQLite has no standalone 'computed' type. SQLite generated columns are created by attaching a ->virtualAs() or ->storedAs() expression to a real base type. The throw fires when the 'computed' pseudo-type is requested directly.
Source
Thrown at src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php:1084
* @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.');
}
/**
* Get the SQL for a generated virtual column modifier.
*
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @param \Illuminate\Support\Fluent $column
* @return string|null
*/
protected function modifyVirtualAs(Blueprint $blueprint, Fluent $column)
{
if (! is_null($virtualAs = $column->virtualAsJson)) {
if ($this->isJsonSelector($virtualAs)) {
$virtualAs = $this->wrapJsonSelector($virtualAs);
}
return " as ({$virtualAs})";
}View on GitHub (pinned to bd6b5437e6)
Solutions
- Use a concrete base type with virtualAs/storedAs: $table->integer('col')->storedAs('expr').
- Driver-guard the 'computed' usage to drivers that support it (sqlsrv).
- For SQLite tests specifically, replace computed with a plain column and recompute in PHP if the expression is simple.
Example fix
// before
$table->computed('total');
// after (SQLite)
$table->integer('total')->storedAs('price * qty'); Defensive patterns
Strategy: validation
Validate before calling
// On SQLite (and MySQL), use a concrete type + virtualAs/storedAs
$table->integer('total')->storedAs('price * qty'); Prevention
- Never call $table->computed() on SQLite — use a base type + modifier.
- Reserve computed() for SQL Server migrations.
- Test generated-column migrations on every supported driver.
When it happens
Trigger: Calling $table->computed('expr') directly on a SQLite connection. Correct SQLite usage is $table->integer('col')->storedAs('expr') or ->virtualAs('expr'). Often hit when running tests on SQLite for a migration that uses the cross-driver 'computed' convenience type.
Common situations: Test suite on SQLite with migrations targeting SQL Server's computed type; auto-generated migrations emitting a generic computed column; misunderstanding the API.
Related errors
- This database driver does not support the computed type.
- This database driver requires a type, see the virtualAs / st
- This database driver does not support modifying generated co
- The database driver in use does not support spatial indexes.
- This database driver does not support dropping foreign keys
AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06).
Data as JSON: /data/errors/6ffa0100d8c9f880.json.
Report an issue: GitHub.