{"record":{"id":"8f64d859efcfc9d4","repo":"laravel/framework","slug":"this-database-driver-requires-a-type-see-the-virt","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/MySqlGrammar.php","lineNumber":1186,"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     * Create the column definition for a vector type.\n     *\n     * @param  \\Illuminate\\Support\\Fluent  $column\n     * @return string\n     */\n    protected function typeVector(Fluent $column)\n    {\n        return isset($column->dimensions) && $column->dimensions !== ''\n            ? \"vector({$column->dimensions})\"\n            : 'vector';\n    }\n\n    /**\n     * Get the SQL for a generated virtual column modifier.\n     *","sourceCodeStart":1168,"sourceCodeEnd":1204,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php#L1168-L1204","documentation":"MySQL's grammar implements typeComputed() as a hard failure. MySQL does not have a standalone COMPUTED column type; a generated column must be declared with a concrete base type together with a virtualAs (VIRTUAL) or storedAs (STORED) expression modifier. Reaching typeComputed means the column was created with ->computed() without an underlying type and without a generation expression.","triggerScenarios":"Declaring $table->computed(...) or setting the Fluent 'computed' type directly on a MySQL blueprint without also setting virtualAs/storedAs and a real column type.","commonSituations":"Porting a migration from another framework that has a native COMPUTED type; using a column-definition helper that emits type 'computed'; hand-crafting a Fluent column instead of using ->virtualAs() / ->storedAs().","solutions":["Use the intended base type plus a generation expression, e.g. $table->integer('total')->storedAs('a + b') or $table->string('upper_name')->virtualAs('UPPER(name)').","If you only need an expression, drop the explicit type call and rely on ->virtualAs() / ->storedAs() which set the type automatically.","Audit custom ColumnDefinition builders to ensure they never emit type === 'computed' on MySQL."],"exampleFix":"// before\n$table->computed('total');\n\n// after\n$table->integer('total')->storedAs('price * qty');\n// or\n$table->string('full_name')->virtualAs('CONCAT(first_name, \" \", last_name)');","handlingStrategy":"validation","validationCode":"// never emit type 'computed' directly on MySQL; always pair a base type with a generation expression\n$table->integer('total')->storedAs('price * qty');\n// or\n$table->string('full_name')->virtualAs('CONCAT(first, last)');","typeGuard":"function generatedColumnIsTyped(\\Illuminate\\Support\\Fluent $c): bool\n{\n    return $c->type !== 'computed'\n        && (! empty($c->virtualAs) || ! empty($c->storedAs));\n}","tryCatchPattern":null,"preventionTips":["Always use a real type method (integer, string, ...) before ->virtualAs()/->storedAs().","Never call a hypothetical ->computed() helper on MySQL blueprints.","Review generated migration files for the literal 'computed' type."],"tags":["database","schema","migrations","mysql","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"}