SonarQube Community to Developer Update: Issue with "duplicate key value violates unique constraint"

Hi, please find attached the structure of the table including indexes.

        Column         |           Type           | Collation | Nullable | Default
-----------------------+--------------------------+-----------+----------+---------
 name                  | character varying(2000)  |           |          |
 description           | character varying(2000)  |           |          |
 enabled               | boolean                  |           | not null | true
 scope                 | character varying(3)     |           |          |
 qualifier             | character varying(10)    |           |          |
 kee                   | character varying(1000)  |           |          |
 language              | character varying(20)    |           |          |
 long_name             | character varying(2000)  |           |          |
 created_at            | timestamp with time zone |           |          |
 path                  | character varying(2000)  |           |          |
 deprecated_kee        | character varying(400)   |           |          |
 uuid                  | character varying(50)    |           | not null |
 branch_uuid           | character varying(50)    |           | not null |
 copy_component_uuid   | character varying(50)    |           |          |
 uuid_path             | character varying(1500)  |           | not null |
 b_changed             | boolean                  |           |          |
 b_copy_component_uuid | character varying(50)    |           |          |
 b_description         | character varying(2000)  |           |          |
 b_enabled             | boolean                  |           |          |
 b_language            | character varying(20)    |           |          |
 b_long_name           | character varying(500)   |           |          |
 b_name                | character varying(500)   |           |          |
 b_path                | character varying(2000)  |           |          |
 b_qualifier           | character varying(10)    |           |          |
 b_uuid_path           | character varying(1500)  |           |          |
 private               | boolean                  |           | not null |
Indexes:
    "components_branch_uuid" btree (branch_uuid)
    "components_kee_branch_uuid" UNIQUE, btree (kee, branch_uuid)
    "components_uuid" UNIQUE, btree (uuid)
    "idx_16621_projects_kee" UNIQUE, btree (kee)
    "idx_16621_projects_project_uuid" btree (branch_uuid)
    "idx_16621_projects_qualifier" btree (qualifier)
    "idx_16621_projects_uuid" btree (uuid)

Hi @antoine.vinot, Can you help us with this problem?

Hi @Ukudkc5Kq2,

Thank you for bearing with us.

I’m surprised by those idx_16621_ indexes and I’m not sure where they originated. Did you perhaps create them manually in the past to solve performance issues?

Also, the index on components kee column should not be UNIQUE.

Note that in 2025.6 version, we are adding a similar index which is not UNIQUE .

Hi @antoine.vinot

Should I just delete the index and try the update again?

Hi!

Yes, I think you should.

The issue is with the unique constraint of this index, as kee might not be unique in this table.

Best

Hi @antoine.vinot, delete index solved our problem.

Thanks for the help!

1 Like