{"record":{"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/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php#L1066-L1102","documentation":"SQLiteGrammar::typeComputed mirrors the MySQL variant: SQLite does not expose a standalone COMPUTED type. Generated columns must be declared with a concrete base type plus a virtualAs (not supported on old SQLite) or storedAs expression. Reaching typeComputed means a column was created with type 'computed' and no expression/type, which SQLite cannot map.","triggerScenarios":"Declaring $table->computed(...) or a custom Fluent column with type 'computed' on a SQLite connection without setting virtualAs/storedAs and a base type.","commonSituations":"Cross-driver migrations using a COMPUTED column abstraction that works on SQL Server but not SQLite; testing on SQLite while production uses SQL Server's COMPUTED; upgrading a package that introduced a computed column.","solutions":["Declare a real base type with a storedAs expression: $table->integer('total')->storedAs('a + b') (requires SQLite >= 3.31 for generated columns).","Drop the computed column on SQLite and compute the value in application code or a view.","Gate the column by driver and skip it on SQLite in tests."],"exampleFix":"// before\n$table->computed('total');\n\n// after\n$table->integer('total')->storedAs('price * qty');","handlingStrategy":"validation","validationCode":"// never emit 'computed' on SQLite; use a base type + storedAs (SQLite >= 3.31)\n$table->integer('total')->storedAs('price * qty');\n// or skip the column on SQLite:\nuse Illuminate\\Support\\Facades\\DB;\nif (DB::connection()->getDriverName() !== 'sqlite') {\n    $table->integer('total')->storedAs('price * qty');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a real type plus storedAs()/virtualAs() on SQLite rather than a 'computed' type.","Ensure SQLite >= 3.31 when using generated columns.","Gate SQL Server-style COMPUTED columns out of SQLite tests."],"tags":["database","schema","migrations","sqlite","generated-columns","driver-unsupported"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}