Preventing duplication on a Postgres table with 2 columns
Enforce a particular canonical ordering on the values:

alter table sometable add constraint sdljfsdfj check (col1&lt;=col2);


If they are in the wrong order, the check constraint will reject them.  They are in the correct order the unique constraint will.

You could couple this with a BEFORE INSERT trigger to swap the order, if you don't want to force the application to deal with that logic.