modified: backend/src/controllers/schemaController.ts
modified: frontend/package.json modified: frontend/src/pages/DatabaseSchema.tsx
This commit is contained in:
@@ -38,13 +38,15 @@ async function parsePostgresSchema(databaseId: string): Promise<SchemaData> {
|
||||
throw new Error('Database not found or not active');
|
||||
}
|
||||
|
||||
// Get all tables
|
||||
// Get all tables with comments via pg_catalog
|
||||
const tablesResult = await pool.query(`
|
||||
SELECT
|
||||
t.table_schema,
|
||||
t.table_name,
|
||||
obj_description((t.table_schema || '.' || t.table_name)::regclass, 'pg_class') as table_comment
|
||||
pg_catalog.obj_description(c.oid, 'pg_class') as table_comment
|
||||
FROM information_schema.tables t
|
||||
LEFT JOIN pg_catalog.pg_class c ON c.relname = t.table_name
|
||||
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace AND n.nspname = t.table_schema
|
||||
WHERE t.table_schema NOT IN ('pg_catalog', 'information_schema')
|
||||
AND t.table_type = 'BASE TABLE'
|
||||
ORDER BY t.table_schema, t.table_name
|
||||
@@ -61,8 +63,10 @@ async function parsePostgresSchema(databaseId: string): Promise<SchemaData> {
|
||||
c.is_nullable,
|
||||
c.column_default,
|
||||
CASE WHEN pk.column_name IS NOT NULL THEN true ELSE false END as is_primary,
|
||||
col_description((c.table_schema || '.' || c.table_name)::regclass, c.ordinal_position) as column_comment
|
||||
pg_catalog.col_description(pc.oid, c.ordinal_position) as column_comment
|
||||
FROM information_schema.columns c
|
||||
LEFT JOIN pg_catalog.pg_class pc ON pc.relname = c.table_name
|
||||
LEFT JOIN pg_catalog.pg_namespace pn ON pn.oid = pc.relnamespace AND pn.nspname = c.table_schema
|
||||
LEFT JOIN (
|
||||
SELECT ku.column_name, ku.table_schema, ku.table_name
|
||||
FROM information_schema.table_constraints tc
|
||||
|
||||
Reference in New Issue
Block a user