Thread: Logical Replication - Adding Not-Null Column Without Default Value

Logical Replication - Adding Not-Null Column Without Default Value

From
Avi Weinberg
Date:

Hi Experts,

 

I'm using logical replication with Postgres 15.

 

I added not-null column without default value to one of my published tables.  The way I so it on publisher side is to add the column as nullable, then update the value based on some logic, and finally make the column not-null.

 

On the subscriber side, if add the column as nullable then add dummy value and finally make it not-null (all in a single truncation), will it be safe to say that the correct values of this column will be logically synchronized from publisher to subscriber and will override the dummy values.  Would, at the end, the two tables on publisher and subscriber have exactly the same values for this column.

 

Do you see a scenario that the tables will not be the same?  Is there a better way to add a not-null column without default value on subscriber side?

 

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.