Last active
August 29, 2015 14:07
-
-
Save jfrost/9c3600077b04e2afe430 to your computer and use it in GitHub Desktop.
Generate your SET ADD TABLE and SET ADD SEQUENCE slonik statements for initial subscription. This will only add tables with primary keys.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT 'SET ADD TABLE (SET id = 1, origin = 1, FULL QUALIFIED NAME = ''' || nspname || '.' || relname || ''', comment=''' || nspname || '.' || relname || ' TABLE'');' FROM pg_class JOIN pg_namespace ON relnamespace = pg_namespace.oid WHERE relkind = 'r' AND relhaspkey AND nspname NOT IN ('information_schema', 'pg_catalog') ORDER BY pg_total_relation_size(pg_class.oid) DESC; | |
SELECT 'SET ADD SEQUENCE (SET id = 1, origin = 1, FULL QUALIFIED NAME = ''' || n.nspname || '.' || c.relname || ''', comment=''' || n.nspname || '.' || c.relname || ' SEQUENCE'');' FROM pg_class c, pg_namespace n WHERE c.relnamespace = n.OID AND c.relkind = 'S'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also important to check that all tables have a pkey: