Logical Replication - Single Destination Table With Multiple Source Tables - How to Handle Structure Changes - Mailing list pgsql-general

From Avi Weinberg
Subject Logical Replication - Single Destination Table With Multiple Source Tables - How to Handle Structure Changes
Date
Msg-id DB9PR07MB71801CEC6FA8E61D233808C8CB1D9@DB9PR07MB7180.eurprd07.prod.outlook.com
Whole thread Raw
Responses Re: Logical Replication - Single Destination Table With Multiple Source Tables - How to Handle Structure Changes  (Vijaykumar Jain <vijaykumarjain.github@gmail.com>)
List pgsql-general

I'm using logical replication to copy data from multiple tables to a single destination table.  At times the structure of the source table needs to change.  However, not all source table will have their structure updated at the same time.  Let's assume, for example, a column type needs to be changed (but solution needs to work for column addition, deletion, rename etc.).  What is the preferable approach:

 

  1. To add another column to the destination table where its type will be the new type.  Source tables, that have the new column type, will write to the new column.  While source tables with old column type will write to the old column.  A view will do the proper casting and will show a single column to user.
  2. Add a new table (versioned: table_name_v2) where source tables that have a new structure will write to the new destination table, while old source tables will write to the old destination table.   A view with UNION and casting will combine all tables.
  3. A better way?

 

 

Thanks

IMPORTANT - This email and any attachments is intended for the above named addressee(s), and may contain information which is confidential or privileged. If you are not the intended recipient, please inform the sender immediately and delete this email: you should not copy or use this e-mail for any purpose nor disclose its contents to any person.

pgsql-general by date:

Previous
From: Ray O'Donnell
Date:
Subject: Re: Overlapping timestamptz ranges with priority
Next
From: Vijaykumar Jain
Date:
Subject: Re: Logical Replication - Single Destination Table With Multiple Source Tables - How to Handle Structure Changes