{"id":"5d0e3db95a1aef12","repo":"laravel/framework","slug":"this-database-driver-does-not-support-the-computed","errorCode":null,"errorMessage":"This database driver does not support the computed type.","messagePattern":"This database driver does not support the computed type\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Schema/Grammars/Grammar.php","lineNumber":352,"sourceCode":"     * @param  \\Illuminate\\Support\\Fluent  $column\n     * @return string\n     */\n    protected function getType(Fluent $column)\n    {\n        return $this->{'type'.ucfirst($column->type)}($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 does not support the computed type.');\n    }\n\n    /**\n     * Create the column definition for a vector type.\n     *\n     * @param  \\Illuminate\\Support\\Fluent  $column\n     * @return string\n     *\n     * @throws \\RuntimeException\n     */\n    protected function typeVector(Fluent $column)\n    {\n        throw new RuntimeException('This database driver does not support the vector type.');\n    }\n\n    /**\n     * Create the column definition for a tsvector type.\n     *","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Database/Schema/Grammars/Grammar.php#L334-L370","documentation":"Base Grammar::typeComputed() throws RuntimeException because the driver's grammar does not support the 'computed' column type (generated columns: STORED/VIRTUAL). typeComputed is dispatched by getType() (Grammar.php:339) when a Blueprint declares $table->computed(...). Drivers that support generated columns override it (MySQL, Postgres, SQL Server); SQLite and others do not.","triggerScenarios":"Declaring $table->computed($expression) or any column whose ->type is 'computed' in a migration on a driver whose grammar does not override typeComputed.","commonSituations":"Cross-driver migration using computed/generated columns running against SQLite tests; CI defaulting to SQLite while app migrations use computed columns.","solutions":["Use MySQL, Postgres, or SQL Server if you need generated columns.","Remove the computed() column on unsupported drivers.","Conditionally add the column only when the driver supports generated columns."],"exampleFix":"// before\nSchema::create('orders', function (Blueprint $t) {\n    $t->integer('qty');\n    $t->integer('price');\n    $t->computed('qty * price')->storedAs('total');\n});\n\n// after\n$driver = DB::connection()->getDriverName();\nSchema::create('orders', function (Blueprint $t) use ($driver) {\n    $t->integer('qty');\n    $t->integer('price');\n    if (in_array($driver, ['mysql','pgsql','sqlsrv'], true)) {\n        $t->computed('qty * price')->storedAs('total');\n    } else {\n        $t->integer('total')->default(0); // fallback\n    }\n});","handlingStrategy":"validation","validationCode":"$driver = DB::connection()->getDriverName();\nif (! in_array($driver, ['mysql','pgsql','sqlsrv'], true)) {\n    return; // computed columns unsupported\n}\nSchema::create('orders', fn (Blueprint $t) => $t->computed('qty * price')->storedAs('total'));","typeGuard":"function driverSupportsComputedColumns(): bool\n{\n    return in_array(DB::connection()->getDriverName(), ['mysql','pgsql','sqlsrv'], true);\n}","tryCatchPattern":"try {\n    Schema::table('orders', fn (Blueprint $t) => $t->computed('qty * price')->storedAs('total'));\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'computed type')) {\n        // fall back to a regular column or application-side computation\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Guard computed()/storedAs()/virtualAs() by driver.","Align CI driver with production.","Provide a fallback column or compute in app code on unsupported drivers."],"tags":["schema","database","driver-support","grammar","columns","computed","generated-columns","migrations"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}