laravel/framework · error · RuntimeException

This database driver does not support the tsvector type.

Error message

This database driver does not support the tsvector type.

What it means

The base Schema\Grammar throws this from typeTsvector() because tsvector is a PostgreSQL-specific full-text-search column type. Only PostgresGrammar overrides typeTsvector(); MySQL, SQLite, SQL Server, and MariaDB fall through to the base method which has no SQL representation. Thrown at migration-compile time when the grammar is asked to render a 'tsvector' column type.

Source

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

     *
     * @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.
     *
     * @param  \Illuminate\Support\Fluent  $column
     * @return string
     *
     * @throws \RuntimeException
     */
    protected function typeTsvector(Fluent $column)
    {
        throw new RuntimeException('This database driver does not support the tsvector type.');
    }

    /**
     * Create the column definition for a raw column type.
     *
     * @param  \Illuminate\Support\Fluent  $column
     * @return string
     */
    protected function typeRaw(Fluent $column)
    {
        return $column->offsetGet('definition');
    }

    /**
     * Add the column modifiers to the definition.
     *
     * @param  string  $sql
     * @param  \Illuminate\Database\Schema\Blueprint  $blueprint

View on GitHub (pinned to bd6b5437e6)

Solutions

  1. Gate the tsvector column behind the connection driver: if (Schema::getConnection()->getDriverName() === 'pgsql') { $table->tsvector('body'); }
  2. Switch the migration's connection to pgsql via Schema::connection('pgsql')->create(...) so the Postgres grammar is used.
  3. Replace the tsvector column with a driver-agnostic type (text/json) and add full-text indexing conditionally per driver.
  4. For non-Postgres drivers, emulate full-text search with a generated text column plus a standard index.

Example fix

// before
Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->tsvector('body');
});

// after
Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->text('body');
    if ($table->getConnection()->getDriverName() === 'pgsql') {
        $table->tsvector('body')->as("to_tsvector('english', body)");
    }
});
Defensive patterns

Strategy: validation

Validate before calling

// Before issuing a tsvector migration, confirm pgsql driver
$driver = Schema::getConnection()->getDriverName();
if ($driver === 'pgsql') {
    // safe to use $table->tsvector('body')
} else {
    // use a fallback column type or skip
}

Type guard

/** @param \Illuminate\\Database\\Schema\\Blueprint $table */
function supportsTsvector(Blueprint $table): bool
{
    return $table->getConnection()->getDriverName() === 'pgsql';
}

Try / catch

try {
    Schema::table('posts', fn (Blueprint $t) => $t->tsvector('body'));
} catch (\RuntimeException $e) {
    if (str_contains($e->getMessage(), 'tsvector type')) {
        // fall back to text + conditional FTS index
    } else {
        throw $e;
    }
}

Prevention

When it happens

Trigger: Calling $table->tsvector('body') (or a column whose type resolves to 'tsvector') inside a migration that runs against a connection other than postgres — e.g. DB_CONNECTION=sqlite in phpunit.xml, or a MySQL prod database. The blueprint dispatches to the connection's grammar, which lacks a typeTsvector override and hits the base RuntimeException.

Common situations: Running migrations on the local SQLite test DB while production uses Postgres; a shared migration file used across multi-DB setups; copying a Postgres-specific migration into a generic starter kit; upgrading a package that introduced tsvector columns without guarding the driver.

Related errors


AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06). Data as JSON: /data/errors/8cc850a85daf367d.json. Report an issue: GitHub.