laravel/framework · error · RuntimeException

This database driver does not support the computed type.

Error message

This database driver does not support the computed type.

What it means

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.

Solutions

  1. On Postgres, express the generated column via raw DDL using DB::statement (e.g. GENERATED ALWAYS AS (...) STORED) instead of the Blueprint computed() helper.
  2. Run migrations that use computed() only on SQLite/SQL Server/MySQL/MariaDB.
  3. In your custom grammar, override typeComputed() to emit the engine's generated-column syntax.

Example fix

// before - throws on Postgres
Schema::create('orders', function (Blueprint $t) {
    $t->integer('qty');
    $t->integer('price');
    $t->integer('total')->computed('qty * price');
});

// after - raw DDL on Postgres
DB::statement("ALTER TABLE orders ADD COLUMN total INTEGER GENERATED ALWAYS AS (qty * price) STORED");
Defensive patterns

Strategy: validation

Validate before calling

use Illuminate\Database\PostgresConnection;

if (Schema::getConnection() instanceof PostgresConnection) {
    throw new \DomainException('Blueprint computed() is not supported by the Postgres grammar; use raw GENERATED ALWAYS AS ... STORED DDL.');
}

Type guard

function supportsBlueprintComputed(\Illuminate\Database\Connection $connection): bool
{
    // computed() is overridden by SQLite, SQL Server, MySQL/MariaDB grammars - NOT Postgres, NOT base
    return ! $connection instanceof \Illuminate\Database\PostgresConnection
        && get_class($connection->getSchemaGrammar()) !== \Illuminate\Database\Schema\Grammars\Grammar::class;
}

Try / catch

try {
    Schema::create('orders', fn ($t) => $t->integer('total')->computed('qty * price'));
} catch (\RuntimeException $e) {
    if (str_contains($e->getMessage(), 'computed type')) {
        DB::statement("ALTER TABLE orders ADD COLUMN total INTEGER GENERATED ALWAYS AS (qty * price) STORED");
    } else {
        throw $e;
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11). Data as JSON: /api/errors/5d0e3db95a1aef12. Report an issue: GitHub.

Appendix: source

Thrown at src/Illuminate/Database/Schema/Grammars/Grammar.php:352

     * @param  \Illuminate\Support\Fluent  $column
     * @return string
     */
    protected function getType(Fluent $column)
    {
        return $this->{'type'.ucfirst($column->type)}($column);
    }

    /**
     * Create the column definition for a generated, computed column type.
     *
     * @param  \Illuminate\Support\Fluent  $column
     * @return void
     *
     * @throws \RuntimeException
     */
    protected function typeComputed(Fluent $column)
    {
        throw new RuntimeException('This database driver does not support the computed type.');
    }

    /**
     * Create the column definition for a vector type.
     *
     * @param  \Illuminate\Support\Fluent  $column
     * @return string
     *
     * @throws \RuntimeException
     */
    protected function typeVector(Fluent $column)
    {
        throw new RuntimeException('This database driver does not support the vector type.');
    }

    /**
     * Create the column definition for a tsvector type.
     *

View on GitHub (pinned to e0f6eb3518)