In order to add a foreign key to an existing table in PostgreSQL, we do the following:
ALTER TABLE nameOfTable
ADD CONSTRAINT fk_key FOREIGN KEY (column_in_current_table) REFERENCES nameOfOtherTable (column_in_other_table);
You can also check and drop an existing foreign key with the same name before adding it again and having PostgreSQL error out:
ALTER TABLE nameOfTable
DROP CONSTRAINT IF EXISTS fk_key,
ADD CONSTRAINT fk_key FOREIGN KEY (column_in_current_table) REFERENCES nameOfOtherTable (column_in_other_table);