Giter VIP home page Giter VIP logo

postgres-to-docs's People

Contributors

4tytwo avatar andreasbjorkegren avatar igeligel avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

postgres-to-docs's Issues

Support materialized views

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'

Exclude tables

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"]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.