How it works…

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 ...

Get PostgreSQL 12 High Availability Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.