{"id":"8cc850a85daf367d","repo":"laravel/framework","slug":"this-database-driver-does-not-support-the-tsvector","errorCode":null,"errorMessage":"This database driver does not support the tsvector type.","messagePattern":"This database driver does not support the tsvector type\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Schema/Grammars/Grammar.php","lineNumber":378,"sourceCode":"     *\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     *\n     * @param  \\Illuminate\\Support\\Fluent  $column\n     * @return string\n     *\n     * @throws \\RuntimeException\n     */\n    protected function typeTsvector(Fluent $column)\n    {\n        throw new RuntimeException('This database driver does not support the tsvector type.');\n    }\n\n    /**\n     * Create the column definition for a raw column type.\n     *\n     * @param  \\Illuminate\\Support\\Fluent  $column\n     * @return string\n     */\n    protected function typeRaw(Fluent $column)\n    {\n        return $column->offsetGet('definition');\n    }\n\n    /**\n     * Add the column modifiers to the definition.\n     *\n     * @param  string  $sql\n     * @param  \\Illuminate\\Database\\Schema\\Blueprint  $blueprint","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Database/Schema/Grammars/Grammar.php#L360-L396","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Gate the tsvector column behind the connection driver: if (Schema::getConnection()->getDriverName() === 'pgsql') { $table->tsvector('body'); }","Switch the migration's connection to pgsql via Schema::connection('pgsql')->create(...) so the Postgres grammar is used.","Replace the tsvector column with a driver-agnostic type (text/json) and add full-text indexing conditionally per driver.","For non-Postgres drivers, emulate full-text search with a generated text column plus a standard index."],"exampleFix":"// before\nSchema::create('posts', function (Blueprint $table) {\n    $table->id();\n    $table->tsvector('body');\n});\n\n// after\nSchema::create('posts', function (Blueprint $table) {\n    $table->id();\n    $table->text('body');\n    if ($table->getConnection()->getDriverName() === 'pgsql') {\n        $table->tsvector('body')->as(\"to_tsvector('english', body)\");\n    }\n});","handlingStrategy":"validation","validationCode":"// Before issuing a tsvector migration, confirm pgsql driver\n$driver = Schema::getConnection()->getDriverName();\nif ($driver === 'pgsql') {\n    // safe to use $table->tsvector('body')\n} else {\n    // use a fallback column type or skip\n}","typeGuard":"/** @param \\Illuminate\\\\Database\\\\Schema\\\\Blueprint $table */\nfunction supportsTsvector(Blueprint $table): bool\n{\n    return $table->getConnection()->getDriverName() === 'pgsql';\n}","tryCatchPattern":"try {\n    Schema::table('posts', fn (Blueprint $t) => $t->tsvector('body'));\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'tsvector type')) {\n        // fall back to text + conditional FTS index\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Driver-guard any driver-specific column type in shared migrations.","Keep Postgres-only migrations on a pgsql connection via Schema::connection().","Run the full migration suite against each driver your app supports in CI."],"tags":["database","schema","migrations","postgres","driver-mismatch"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}