{"record":{"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/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/Schema/Grammars/Grammar.php#L334-L370","documentation":"Grammar::typeComputed() throws RuntimeException on the base; SQLiteGrammar, SqlServerGrammar, and MySqlGrammar override it (MariaDb inherits via MySql). PostgresGrammar does NOT override it, so Postgres falls through to the throwing base - generated/stored computed columns are not supported by this codebase's Postgres grammar. It is the type-renderer invoked by the Blueprint when a column is defined as computed.","triggerScenarios":"Defining a column with ->computed(...) or a stored/generated expression (Blueprint's computed column type) in a migration that runs on Postgres, or on any custom grammar that does not override typeComputed.","commonSituations":"Porting a MySQL/SQL Server schema with GENERATED ALWAYS AS (...) columns onto Postgres and expecting the same Blueprint call to work; running a shared migration set across engines where one of them is Postgres.","solutions":["On Postgres, express the generated column via raw DDL using DB::statement (e.g. GENERATED ALWAYS AS (...) STORED) instead of the Blueprint computed() helper.","Run migrations that use computed() only on SQLite/SQL Server/MySQL/MariaDB.","In your custom grammar, override typeComputed() to emit the engine's generated-column syntax."],"exampleFix":"// before - throws on Postgres\nSchema::create('orders', function (Blueprint $t) {\n    $t->integer('qty');\n    $t->integer('price');\n    $t->integer('total')->computed('qty * price');\n});\n\n// after - raw DDL on Postgres\nDB::statement(\"ALTER TABLE orders ADD COLUMN total INTEGER GENERATED ALWAYS AS (qty * price) STORED\");","handlingStrategy":"validation","validationCode":"use Illuminate\\Database\\PostgresConnection;\n\nif (Schema::getConnection() instanceof PostgresConnection) {\n    throw new \\DomainException('Blueprint computed() is not supported by the Postgres grammar; use raw GENERATED ALWAYS AS ... STORED DDL.');\n}","typeGuard":"function supportsBlueprintComputed(\\Illuminate\\Database\\Connection $connection): bool\n{\n    // computed() is overridden by SQLite, SQL Server, MySQL/MariaDB grammars - NOT Postgres, NOT base\n    return ! $connection instanceof \\Illuminate\\Database\\PostgresConnection\n        && get_class($connection->getSchemaGrammar()) !== \\Illuminate\\Database\\Schema\\Grammars\\Grammar::class;\n}","tryCatchPattern":"try {\n    Schema::create('orders', fn ($t) => $t->integer('total')->computed('qty * price'));\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'computed type')) {\n        DB::statement(\"ALTER TABLE orders ADD COLUMN total INTEGER GENERATED ALWAYS AS (qty * price) STORED\");\n    } else {\n        throw $e;\n    }\n}","preventionTips":["On Postgres, define generated columns with raw DDL rather than the Blueprint computed() helper.","Keep computed() migrations on SQLite/MySQL/SQL Server/MariaDB.","When porting a schema between engines, audit every generated-column definition."],"tags":["schema","grammar","database-driver","postgres","computed-columns","runtime-exception"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}