feat: schema graph via FK introspection

- GET .../db-connections/:id/foreign-keys — per-dialect
  information_schema/pragma query through dbx_execute_query,
  identifier-whitelisted, read-role gated
- Databases page: Graph tab renders tables as radial SVG nodes with
  FK edges; hover highlights adjacency, click inspects the table
- demo stubs for edges + wider demo table set

Authored By: TDvorak <[email protected]>
This commit is contained in:
Tomas Dvorak committed 2026-09-16 15:27:28 +02:00
1 parent 627bd89d5e
commit d57f30cd59
12 files changed
+496 -2

No files matched your search

+25 -1
View File
@@ -353,7 +353,17 @@ let dbConnections: DBConnection[] = [
},
];
const demoTables = ["users", "projects", "api_keys", "audit_logs", "buckets"];
const demoTables = [
"users",
"organizations",
"projects",
"api_keys",
"audit_logs",
"buckets",
"bucket_objects",
"collections",
"documents",
];
const demoColumns: Record<string, string[][]> = {
users: [
@@ -833,6 +843,20 @@ class DemoService {
};
}
async listDbForeignKeys() {
await this.delay();
return {
edges: [
{ schema: "core", table: "projects", column: "organization_id", ref_schema: "core", ref_table: "organizations", ref_column: "id" },
{ schema: "core", table: "api_keys", column: "project_id", ref_schema: "core", ref_table: "projects", ref_column: "id" },
{ schema: "core", table: "audit_logs", column: "project_id", ref_schema: "core", ref_table: "projects", ref_column: "id" },
{ schema: "core", table: "audit_logs", column: "organization_id", ref_schema: "core", ref_table: "organizations", ref_column: "id" },
{ schema: "core", table: "bucket_objects", column: "bucket_id", ref_schema: "core", ref_table: "buckets", ref_column: "id" },
{ schema: "core", table: "documents", column: "collection_id", ref_schema: "core", ref_table: "collections", ref_column: "id" },
],
};
}
async getDbSchemaContext() {
await this.delay();
return { context: "## users\nType: BASE TABLE\n- id uuid NOT NULL PK\n- email text NOT NULL" };