The job of this recipe is to either transfer everything, or some subset of the data we wish to retain. We start this process by listing all of the schemas in our database using a specially constructed query that omits any likely PostgreSQL catalog tables and the ever-present information_schema, as well as pglogical itself. From here we can decide to leave the list unadulterated, or remove rows for schemas we want to discard.
We then perform the same task for all tables in the database. It's important to know whether or not a table has a primary key. As a consequence, the query we use here is rather complicated, using PostgreSQL catalog tables such as pg_class, pg_namespace, and pg_constraint. The purpose of this query is to ...