klarna-incubator / postgres-to-docs Goto Github PK
View Code? Open in Web Editor NEWThe smoooth way to document your postgres database
License: Apache License 2.0
The smoooth way to document your postgres database
License: Apache License 2.0
Neither the views
and table
queries returns materialized views.
One solution is to introduce another select and run
select * from pg_matviews;
Another option (that requires refactoring) is to use this query from a similar python package:
https://github.com/PiskarevSA/pg_autodoc/blob/master/collect_info.py#L68
It returns all tables, views and materialized views in one query
Slightly modified, it could look like this:
SELECT
nspname as namespace,
relname as tablename,
pg_catalog.pg_get_userbyid(relowner) AS tableowner,
pg_class.oid,
pg_catalog.obj_description(pg_class.oid, 'pg_class') as table_description,
relacl,
CASE
WHEN relkind = 'f' THEN
'foreign table'
WHEN relkind = 'm' THEN
'materialized view'
WHEN relkind = 's' THEN
'special'
WHEN relkind = 'r' THEN
'table'
ELSE
'view'
END as reltype,
CASE
WHEN relkind IN ('m', 'v') THEN
pg_get_viewdef(pg_class.oid)
ELSE
NULL
END as view_definition
FROM pg_catalog.pg_class
JOIN pg_catalog.pg_namespace ON (relnamespace = pg_namespace.oid)
WHERE
relkind IN ('f', 'm', 's', 'r', 'v')
AND relname NOT LIKE 'sql_%'
AND relname NOT LIKE 'pg_%'
AND nspname <> 'information_schema'
Add ability to exclude tables from the results. For example, prevent migration tables from showing up. Could be added as a key in the config file
{
...
"exclude": ["migrations"]
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.