Add unique constraint to an existing PostgreSQL index : <p>I have an index in my PostgreSQL 9.3 database:</p>

<pre><code>CREATE INDEX index_foos_on_bar_and_baz ON foos USING btree (bar, baz);
</code></pre>

<p>(from a schema migration using Ruby on Rails)</p>

<p>The index is present and made things faster. Now that I've cleaned up duplicate foos, I'd like to make this index unique:</p>

<pre><code>CREATE UNIQUE INDEX index_foos_on_bar_and_baz ON foos USING btree (bar, baz);
</code></pre>

<p>Is there a way to alter the existing index and make it unique? Or is it easier/faster to delete the existing index and create a new, unique one?</p>
