{"record":{"id":"58de220de6e5dbee","repo":"laravel/framework","slug":"this-database-driver-does-not-support-modifying-ge","errorCode":null,"errorMessage":"This database driver does not support modifying generated columns.","messagePattern":"This database driver does not support modifying generated columns\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php","lineNumber":1283,"sourceCode":"        }\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     * @throws \\LogicException\n     */\n    protected function modifyVirtualAs(Blueprint $blueprint, Fluent $column)\n    {\n        if ($column->change) {\n            if (array_key_exists('virtualAs', $column->getAttributes())) {\n                return is_null($column->virtualAs)\n                    ? 'drop expression if exists'\n                    : throw new LogicException('This database driver does not support modifying generated columns.');\n            }\n\n            return null;\n        }\n\n        if (! is_null($column->virtualAs)) {\n            return \" generated always as ({$this->getValue($column->virtualAs)}) virtual\";\n        }\n    }\n\n    /**\n     * Get the SQL for a generated stored column modifier.\n     *\n     * @param  \\Illuminate\\Database\\Schema\\Blueprint  $blueprint\n     * @param  \\Illuminate\\Support\\Fluent  $column\n     * @return string|null\n     *\n     * @throws \\LogicException","sourceCodeStart":1265,"sourceCodeEnd":1301,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php#L1265-L1301","documentation":"PostgresGrammar::modifyVirtualAs throws a LogicException when a column is being modified ($column->change is true) AND a non-null virtualAs attribute is present. PostgreSQL cannot ALTER a generated VIRTUAL expression in place; you must drop and recreate the column. Setting virtualAs back to null is allowed (it emits 'drop expression if exists'), but providing a new expression on a change is not.","triggerScenarios":"Using $table->integer('col')->virtualAs('expr')->change() (i.e. a column modification that supplies a non-null virtualAs) on a Postgres connection.","commonSituations":"Calling ->change() on a migration that also redefines the generation expression; trying to repoint a generated column at a new formula in a Postgres-only deploy; migration scaffolding tools that always resend all attributes on change.","solutions":["Drop the virtualAs attribute when calling ->change() for unrelated modifications: $table->integer('col')->change() without virtualAs.","To change the expression, split into two migrations: drop the column (or drop expression), then re-add it with the new virtualAs.","If the intent was to remove the generation expression, call ->virtualAs(null)->change() which emits 'drop expression if exists'."],"exampleFix":"// before\n$table->integer('total')->virtualAs('a + b')->change();\n\n// after (replace the expression)\n// migration 1\nSchema::table('orders', fn (Blueprint $t) => $t->dropColumn('total'));\n// migration 2\nSchema::table('orders', fn (Blueprint $t) => $t->integer('total')->virtualAs('a + b + fee'));","handlingStrategy":"validation","validationCode":"// when modifying a column on Postgres, do NOT resend virtualAs unless you mean to drop it\n$col = $table->integer('total');\nif (! $columnWantsNewExpression) {\n    // just change another attribute\n    $col->nullable(false)->change();\n} else {\n    // to remove the expression:\n    $col->virtualAs(null)->change();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Split generated-column expression changes into drop + re-add migrations on Postgres.","When calling ->change(), only set the attributes you intend to alter.","Use ->virtualAs(null)->change() to drop an expression, never a new expression."],"tags":["database","schema","migrations","postgres","generated-columns","driver-unsupported","alter-table"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}