DB migration fails on upgrade

Make sure to tell us:

  • What version are you upgrading from?
    sonarqube 9.2.4 → 9.9(LTS)
  • System information (Operating system, Java version, Database provider/version)
    OS: centos 7.9
    Java: jdk 17
    DB: postgres 12
  • What’s the issue you’re facing?
    failed on migration step #6407
    Fail to execute CREATE UNIQUE INDEX uniq_rule_desc_sections_kee ON rule_desc_sections (rule_uuid, kee)
    ERROR: could not create unique index “uniq_rule_desc_sections_kee” key(rule_uuid, kee)=(6645, how_to_fix) is duplicated.
    The same error occurs when you enter the postgresql console and type the command.
    so, I entered the following command
    sonaruqbe=# select rule_uuid, kee from rule_desc_sections GROUP BY rule_uuid, kee HAVING COUNT(*) > 1;
    (31 rows)

Hello @jk.park,

Thanks for your input.

It looks like at some point your SonarQube managed to start with the newest data from plugins although the DB was not migrated. This leads to this situation.

To overcome this error, can you run this manual insert:

insert into schema_migrations (version) values ('6407');

And then re-start SonarQube? This should allow to progress with migrations.

In case it fails later on, we recommend you to simply clean up all the data of that table (it will be re-created automatically):

delete * from rule_desc_sections;

Please let us know if that solved your problem.


Thank you. It worked well

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.