DB migration error while upgrading from 9.5 to 9.7: duplicate key value violates unique constraint

Hello @c.joosse and welcome to the community!

You can have a look to this post with a similar issue.

As explained in the other post, the index project_kee is dropped in 9.7, and is replaced by another one, but it is also expected that the index has exactly the name projects_kee and not idx_16633_projects_kee.

Could you please provide us with the following information:

  • The first version of SonarQube that was setup on that instance
  • The result of this command on the sq schema (schema name might need to be adapted):
SELECT
    tablename,
    indexname,
    indexdef
FROM
    pg_indexes
WHERE
        schemaname = 'public'
ORDER BY
    tablename,
    indexname;
  • If you use some specific tools to backup and restore the database (such as pgloader)

So for now I think it is safe to remove it manually, but you may encounter other issues in the future, so it is important that we understand how those index names are created

1 Like