From 84d4666710e75f5d7364144416fa0d3bdb33fd7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederic=20H=C3=BCbner?= Date: Wed, 22 Jul 2026 16:11:25 +0200 Subject: [PATCH] fix(sonarqube): tolerate missing migration indexes --- backend/impls/dalgorm/dalgorm.go | 3 +++ .../sonarqube/e2e/issue_code_block_long_component_test.go | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/backend/impls/dalgorm/dalgorm.go b/backend/impls/dalgorm/dalgorm.go index ba635355f41..0445995fd50 100644 --- a/backend/impls/dalgorm/dalgorm.go +++ b/backend/impls/dalgorm/dalgorm.go @@ -453,6 +453,9 @@ func (d *Dalgorm) RenameTable(oldName, newName string) errors.Error { // DropIndexes drops indexes for specified table func (d *Dalgorm) DropIndexes(table string, indexNames ...string) errors.Error { for _, indexName := range indexNames { + if !d.db.Migrator().HasIndex(table, indexName) { + continue + } err := d.db.Migrator().DropIndex(table, indexName) if err != nil { return d.convertGormError(err) diff --git a/backend/plugins/sonarqube/e2e/issue_code_block_long_component_test.go b/backend/plugins/sonarqube/e2e/issue_code_block_long_component_test.go index 8076fa3a859..e1a7d52b5a5 100644 --- a/backend/plugins/sonarqube/e2e/issue_code_block_long_component_test.go +++ b/backend/plugins/sonarqube/e2e/issue_code_block_long_component_test.go @@ -80,6 +80,12 @@ func TestSonarqubeIssueCodeBlockLongComponent(t *testing.T) { &sonarqubeIssueCodeBlockBeforeText{}, &cqIssueCodeBlockBeforeText{}, )) + require.NoError(t, dataflowTester.Db.Migrator().DropIndex( + "cq_issue_code_blocks", "idx_cq_issue_code_blocks_component", + )) + require.NoError(t, dataflowTester.Db.Migrator().DropIndex( + "_tool_sonarqube_issue_code_blocks", "idx__tool_sonarqube_issue_code_blocks_component", + )) existingComponent := "existing:component" require.NoError(t, dataflowTester.Db.Create(&sonarqubeIssueCodeBlockBeforeText{