How to replace foreign reference in PostgreSQL?
Sample data,

CREATE TABLE foo ( a int UNIQUE, b int UNIQUE );
CREATE TABLE bar ( c int REFERENCES foo(a) );


Simple ALTER statement,

ALTER TABLE bar
  DROP CONSTRAINT bar_c_fkey,
  ADD FOREIGN KEY (c) REFERENCES foo(b);


And, that worked!

                Table "public.bar"
 Column |  Type   | Collation | Nullable | Default 
--------+---------+-----------+----------+---------
 c      | integer |           |          | 
Foreign-key constraints:
    "bar_c_fkey" FOREIGN KEY (c) REFERENCES foo(b)