Skip to content

[Bug][SonarQube] Migration fails when issue code block component index is absent #9011

Description

@frederic-huebner

Summary

A fresh MySQL installation can fail while applying the SonarQube and domain migrations at version 20260701000000 when the legacy component index is absent.

Dalgorm.DropIndexes unconditionally calls GORM's DropIndex, so MySQL aborts the migration with error 1091 instead of treating the already-absent index as the desired state.

Reproduction

  1. Start a fresh MySQL 8 database.
  2. Create the legacy cq_issue_code_blocks and _tool_sonarqube_issue_code_blocks tables, then remove idx_cq_issue_code_blocks_component and idx__tool_sonarqube_issue_code_blocks_component.
  3. Apply both version 20260701000000 migrations that change component to text.

Actual result: the first migration attempts to drop the absent index and fails with Error 1091 (42000): Can't DROP 'idx_cq_issue_code_blocks_component'; check that column/key exists.

Expected result: migration is idempotent when an index is already absent, while present indexes continue to be dropped before the column becomes text.

Evidence

The targeted regression test TestSonarqubeIssueCodeBlockLongComponent reproduces the MySQL 1091 failure before the fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions