{"id":"6ffa0100d8c9f880","repo":"laravel/framework","slug":"this-database-driver-requires-a-type-see-the-virt-6ffa01","errorCode":null,"errorMessage":"This database driver requires a type, see the virtualAs / storedAs modifiers.","messagePattern":"This database driver requires a type, see the virtualAs / storedAs modifiers\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php","lineNumber":1084,"sourceCode":"     * @param  \\Illuminate\\Support\\Fluent  $column\n     * @return string\n     */\n    protected function typeGeography(Fluent $column)\n    {\n        return $this->typeGeometry($column);\n    }\n\n    /**\n     * Create the column definition for a generated, computed column type.\n     *\n     * @param  \\Illuminate\\Support\\Fluent  $column\n     * @return void\n     *\n     * @throws \\RuntimeException\n     */\n    protected function typeComputed(Fluent $column)\n    {\n        throw new RuntimeException('This database driver requires a type, see the virtualAs / storedAs modifiers.');\n    }\n\n    /**\n     * Get the SQL for a generated virtual column modifier.\n     *\n     * @param  \\Illuminate\\Database\\Schema\\Blueprint  $blueprint\n     * @param  \\Illuminate\\Support\\Fluent  $column\n     * @return string|null\n     */\n    protected function modifyVirtualAs(Blueprint $blueprint, Fluent $column)\n    {\n        if (! is_null($virtualAs = $column->virtualAsJson)) {\n            if ($this->isJsonSelector($virtualAs)) {\n                $virtualAs = $this->wrapJsonSelector($virtualAs);\n            }\n\n            return \" as ({$virtualAs})\";\n        }","sourceCodeStart":1066,"sourceCodeEnd":1102,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php#L1066-L1102","documentation":"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.","triggerScenarios":"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.","commonSituations":"Test suite on SQLite with migrations targeting SQL Server's computed type; auto-generated migrations emitting a generic computed column; misunderstanding the API.","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."],"exampleFix":"// before\n$table->computed('total');\n\n// after (SQLite)\n$table->integer('total')->storedAs('price * qty');","handlingStrategy":"validation","validationCode":"// On SQLite (and MySQL), use a concrete type + virtualAs/storedAs\n$table->integer('total')->storedAs('price * qty');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["database","schema","sqlite","migrations","generated-columns"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}