Postgresql Add Constraint Foreign Key If Clauses