use the preffered method of creating an unique index in postgresql 

As suggested by the manual. Fixes #788. All tests pass and tested it manually to ensure the syntax is correct.