0

I accidentally (during a database migration) created a unique constraint on the columns, that already had the same unique constraint defined. Basically I ended up with this:

=> select * from information_schema.table_constraints where table_name = 'users' and constraint_type = 'UNIQUE';
 constraint_catalog | constraint_schema | constraint_name  | table_catalog | table_schema | table_name | constraint_type | is_deferrable | initially_deferred
--------------------+-------------------+------------------+---------------+--------------+------------+-----------------+---------------+--------------------
 fo-auth            | public            | users_email_key  | fo-auth       | public       | users      | UNIQUE          | NO            | NO
 fo-auth            | public            | users_email_key1 | fo-auth       | public       | users      | UNIQUE          | NO            | NO
(2 rows)

Is this something to worry about, or can I live with it?

1 Answer 1

1

Just drop the redundant constraint:

alter table users drop constraint users_email_key1;

Two same constraints don't do any harm, but unnecessarily make inserts and updates longer.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.