{"record":{"id":"cfbaf01e64330fff","repo":"laravel/framework","slug":"the-database-driver-in-use-does-not-support-spatia","errorCode":null,"errorMessage":"The database driver in use does not support spatial indexes.","messagePattern":"The database driver in use does not support spatial indexes\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php","lineNumber":440,"sourceCode":"            $schema ? $this->wrapValue($schema).'.' : '',\n            $this->wrap($command->index),\n            $this->wrapTable($table),\n            $this->columnize($command->columns)\n        );\n    }\n\n    /**\n     * Compile a spatial index key command.\n     *\n     * @param  \\Illuminate\\Database\\Schema\\Blueprint  $blueprint\n     * @param  \\Illuminate\\Support\\Fluent  $command\n     * @return void\n     *\n     * @throws \\RuntimeException\n     */\n    public function compileSpatialIndex(Blueprint $blueprint, Fluent $command)\n    {\n        throw new RuntimeException('The database driver in use does not support spatial indexes.');\n    }\n\n    /**\n     * Compile a foreign key command.\n     *\n     * @param  \\Illuminate\\Database\\Schema\\Blueprint  $blueprint\n     * @param  \\Illuminate\\Support\\Fluent  $command\n     * @return string|null\n     */\n    public function compileForeign(Blueprint $blueprint, Fluent $command)\n    {\n        // Handled on table creation or alteration...\n    }\n\n    /**\n     * Compile a drop table command.\n     *\n     * @param  \\Illuminate\\Database\\Schema\\Blueprint  $blueprint","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php#L422-L458","documentation":"SQLiteGrammar::compileSpatialIndex unconditionally throws because SQLite (without the SpatiaLite extension, which Laravel does not wire up) has no native spatial index command. Blueprint->spatialIndex() dispatches to this compiler method on a SQLite connection and fails immediately.","triggerScenarios":"Calling $table->spatialIndex('geom') or ->spatialIndex(['lat','lng']) while the Schema connection is SQLite (e.g. the default testing or in-memory connection).","commonSituations":"Running migration tests against :memory: SQLite but the production migration uses Postgres/MySQL spatial indexes; CI configured with SQLite while staging/prod use a spatial-capable database.","solutions":["Run the migration against Postgres or MySQL (5.7+/MariaDB) where spatialIndex compiles to SPATIAL INDEX.","Gate the spatial index by connection type so SQLite test runs skip it: if (! DB::connection() instanceof \\Illuminate\\Database\\SQLiteConnection) { $table->spatialIndex('geom'); }.","In tests, use the RefreshDatabase trait with a Postgres/MySQL test database or skip the offending migration via Schema::getConnection()->getDriverName() checks."],"exampleFix":"// before\n$table->spatialIndex('location');\n\n// after (driver-gated)\nuse Illuminate\\Support\\Facades\\DB;\n\nif (DB::connection()->getDriverName() !== 'sqlite') {\n    $table->spatialIndex('location');\n}","handlingStrategy":"validation","validationCode":"use Illuminate\\Support\\Facades\\DB;\n\nif (DB::connection()->getDriverName() !== 'sqlite') {\n    $table->spatialIndex('location');\n}","typeGuard":"function supportsSpatialIndex(?\\Illuminate\\Database\\ConnectionInterface $c = null): bool {\n    $c ??= \\Illuminate\\Support\\Facades\\DB::connection();\n    return in_array($c->getDriverName(), ['mysql', 'mariadb', 'pgsql'], true);\n}","tryCatchPattern":null,"preventionTips":["Guard spatial index creation by driver name.","Run the production migration's tests against a spatial-capable DB.","Use a separate test connection for spatial features rather than SQLite :memory:."],"tags":["database","schema","migrations","sqlite","spatial","driver-unsupported"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}