{"record":{"id":"3633cb68e9e4ba63","repo":"laravel/framework","slug":"this-database-driver-does-not-support-retrieving-f","errorCode":null,"errorMessage":"This database driver does not support retrieving foreign keys.","messagePattern":"This database driver does not support retrieving foreign keys\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Schema/Grammars/Grammar.php","lineNumber":182,"sourceCode":"     * @throws \\RuntimeException\n     */\n    public function compileVectorIndex(Blueprint $blueprint, Fluent $command)\n    {\n        throw new RuntimeException('The database driver in use does not support vector indexes.');\n    }\n\n    /**\n     * Compile the query to determine the foreign keys.\n     *\n     * @param  string|null  $schema\n     * @param  string  $table\n     * @return string\n     *\n     * @throws \\RuntimeException\n     */\n    public function compileForeignKeys($schema, $table)\n    {\n        throw new RuntimeException('This database driver does not support retrieving foreign keys.');\n    }\n\n    /**\n     * Compile a rename column command.\n     *\n     * @param  \\Illuminate\\Database\\Schema\\Blueprint  $blueprint\n     * @param  \\Illuminate\\Support\\Fluent  $command\n     * @return list<string>|string\n     */\n    public function compileRenameColumn(Blueprint $blueprint, Fluent $command)\n    {\n        return sprintf('alter table %s rename column %s to %s',\n            $this->wrapTable($blueprint),\n            $this->wrap($command->from),\n            $this->wrap($command->to)\n        );\n    }\n","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/Schema/Grammars/Grammar.php#L164-L200","documentation":"Grammar::compileForeignKeys() throws RuntimeException on the base class; all four shipped grammars override it. Reaching the base means the connection's SchemaGrammar is the unimplemented base Grammar. Builder::getForeignKeys() routes here.","triggerScenarios":"Schema::getForeignKeys($table) on a connection whose SchemaGrammar is the base Grammar (custom driver not implementing the method).","commonSituations":"Custom/community driver whose grammar was never filled in; an introspection/admin tool that calls getForeignKeys on every configured connection.","solutions":["Use a supported driver (sqlite/mysql/pgsql/sqlsrv) for foreign-key introspection.","Override compileForeignKeys($schema, $table) in your custom grammar.","Query information_schema.table_constraints / pg_constraint directly."],"exampleFix":"// before\n$fks = Schema::connection('custom')->getForeignKeys('orders');\n\n// after\n$fks = DB::connection('custom')->select(\n    \"SELECT constraint_name FROM information_schema.table_constraints WHERE table_name = ? AND constraint_type = 'FOREIGN KEY'\",\n    ['orders']\n);","handlingStrategy":"type-guard","validationCode":"$grammar = Schema::getConnection()->getSchemaGrammar();\nif (get_class($grammar) === \\Illuminate\\Database\\Schema\\Grammars\\Grammar::class) {\n    throw new \\DomainException('Connection uses the base Grammar; cannot list foreign keys.');\n}","typeGuard":"function supportsCompileForeignKeys(\\Illuminate\\Database\\Schema\\Grammars\\Grammar $grammar): bool\n{\n    return (new \\ReflectionMethod($grammar, 'compileForeignKeys'))\n        ->getDeclaringClass()->getName() !== \\Illuminate\\Database\\Schema\\Grammars\\Grammar::class;\n}","tryCatchPattern":"try {\n    $fks = Schema::getForeignKeys('orders');\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'retrieving foreign keys')) {\n        $fks = DB::select(\"SELECT * FROM information_schema.table_constraints WHERE table_name = ? AND constraint_type = 'FOREIGN KEY'\", ['orders']);\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Bind a real grammar in custom connections; never ship the base Grammar.","Implement compileForeignKeys when authoring a new grammar.","In admin tooling, gate foreign-key introspection on the grammar class."],"tags":["schema","grammar","database-driver","foreign-keys","runtime-exception"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}