new file: backend/src/controllers/schemaController.ts

new file:   backend/src/migrations/008_add_database_schemas.sql
	modified:   backend/src/routes/sqlInterface.ts
	modified:   frontend/package.json
	modified:   frontend/src/App.tsx
	modified:   frontend/src/components/Sidebar.tsx
	new file:   frontend/src/pages/DatabaseSchema.tsx
	modified:   frontend/src/services/api.ts
This commit is contained in:
2026-01-27 23:42:25 +03:00
parent a873e18d35
commit 89b5a86bda
8 changed files with 525 additions and 1 deletions

View File

@@ -187,4 +187,42 @@ export const sqlInterfaceApi = {
api.post<SqlQueryResult>('/workbench/execute', { database_id: databaseId, query }),
};
// Schema API
export interface ColumnInfo {
name: string;
type: string;
nullable: boolean;
default_value: string | null;
is_primary: boolean;
comment: string | null;
}
export interface ForeignKey {
column: string;
references_table: string;
references_column: string;
constraint_name: string;
}
export interface TableInfo {
name: string;
schema: string;
comment: string | null;
columns: ColumnInfo[];
foreign_keys: ForeignKey[];
}
export interface SchemaData {
tables: TableInfo[];
updated_at: string;
}
export const schemaApi = {
getSchema: (databaseId: string) =>
api.get<{ success: boolean; data: SchemaData }>(`/workbench/schema/${databaseId}`),
refreshSchema: (databaseId: string) =>
api.post<{ success: boolean; data: SchemaData }>(`/workbench/schema/${databaseId}/refresh`),
};
export default api;