The following bug has been logged on the website:
Bug reference: 17435
Logged by: Rafael Sousa
Email address: rafmsou(at)gmail(dot)com
PostgreSQL version: 12.10
Operating system: macOS, linux
Description:
The statement below aims to add a new column CCC on table XXX and create a
FK constraint to YYY at the same time:
"alter table XXX add column if not exists CCC uuid references YYY (id);"
I checked the docs and other forum and that seems to be possible. The
problem is that we end up with multiple FKs created on column CCC when
running the statement multiple times. I would hope no FK gets created when
the column already exists, is that correct?