This is an automated email from the ASF dual-hosted git repository.

klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new b4b53b8a6 fix(domain): migrate issue component to text (#8987)
b4b53b8a6 is described below

commit b4b53b8a6da9e528237b6f0d1c638a8bd331c0b5
Author: Dirk <[email protected]>
AuthorDate: Sun Jul 19 05:24:46 2026 +0200

    fix(domain): migrate issue component to text (#8987)
    
    Signed-off-by: DoDiODev <[email protected]>
    Co-authored-by: Klesh Wong <[email protected]>
---
 .../20260629_change_issue_component_to_text.go     | 41 +++++++++++
 ...20260629_change_issue_component_to_text_test.go | 82 ++++++++++++++++++++++
 backend/core/models/migrationscripts/register.go   |  1 +
 3 files changed, 124 insertions(+)

diff --git 
a/backend/core/models/migrationscripts/20260629_change_issue_component_to_text.go
 
b/backend/core/models/migrationscripts/20260629_change_issue_component_to_text.go
new file mode 100644
index 000000000..94d965d62
--- /dev/null
+++ 
b/backend/core/models/migrationscripts/20260629_change_issue_component_to_text.go
@@ -0,0 +1,41 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+       "github.com/apache/incubator-devlake/core/context"
+       "github.com/apache/incubator-devlake/core/errors"
+       "github.com/apache/incubator-devlake/core/plugin"
+)
+
+var _ plugin.MigrationScript = (*changeIssueComponentToText)(nil)
+
+type changeIssueComponentToText struct{}
+
+func (*changeIssueComponentToText) Up(basicRes context.BasicRes) errors.Error {
+       // The 20240813 migration targeted the non-existent plural "components" 
column.
+       return basicRes.GetDal().ModifyColumnType("issues", "component", "text")
+}
+
+func (*changeIssueComponentToText) Version() uint64 {
+       return 20260629120000
+}
+
+func (*changeIssueComponentToText) Name() string {
+       return "change issues.component type to text"
+}
diff --git 
a/backend/core/models/migrationscripts/20260629_change_issue_component_to_text_test.go
 
b/backend/core/models/migrationscripts/20260629_change_issue_component_to_text_test.go
new file mode 100644
index 000000000..482c42b50
--- /dev/null
+++ 
b/backend/core/models/migrationscripts/20260629_change_issue_component_to_text_test.go
@@ -0,0 +1,82 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+       "testing"
+
+       "github.com/apache/incubator-devlake/core/context"
+       "github.com/apache/incubator-devlake/core/dal"
+       "github.com/apache/incubator-devlake/core/errors"
+)
+
+type modifyColumnTypeCall struct {
+       tableName  string
+       columnName string
+       columnType string
+}
+
+type recordingDal struct {
+       dal.Dal
+       call *modifyColumnTypeCall
+}
+
+func (d *recordingDal) ModifyColumnType(tableName string, columnName string, 
columnType string) errors.Error {
+       d.call = &modifyColumnTypeCall{tableName, columnName, columnType}
+       return nil
+}
+
+type basicResWithDal struct {
+       context.BasicRes
+       database dal.Dal
+}
+
+func (r *basicResWithDal) GetDal() dal.Dal {
+       return r.database
+}
+
+func TestChangeIssueComponentToText(t *testing.T) {
+       database := new(recordingDal)
+       script := new(changeIssueComponentToText)
+
+       if err := script.Up(&basicResWithDal{database: database}); err != nil {
+               t.Fatalf("migration failed: %v", err)
+       }
+
+       want := &modifyColumnTypeCall{"issues", "component", "text"}
+       if database.call == nil || *database.call != *want {
+               t.Fatalf("ModifyColumnType call = %#v, want %#v", 
database.call, want)
+       }
+       if script.Version() != 20260629120000 {
+               t.Fatalf("Version() = %d, want 20260629120000", 
script.Version())
+       }
+       if script.Name() != "change issues.component type to text" {
+               t.Fatalf("Name() = %q, want %q", script.Name(), "change 
issues.component type to text")
+       }
+
+       found := false
+       for _, registeredScript := range All() {
+               if registeredScript.Version() == script.Version() {
+                       found = true
+                       break
+               }
+       }
+       if !found {
+               t.Fatalf("migration version %d is not registered", 
script.Version())
+       }
+}
diff --git a/backend/core/models/migrationscripts/register.go 
b/backend/core/models/migrationscripts/register.go
index adef98ef8..e25363a1b 100644
--- a/backend/core/models/migrationscripts/register.go
+++ b/backend/core/models/migrationscripts/register.go
@@ -145,6 +145,7 @@ func All() []plugin.MigrationScript {
                new(modifyCicdDeploymentsToText),
                new(increaseCqIssuesProjectKeyLength),
                new(addAuthSessions),
+               new(changeIssueComponentToText),
                new(changeCqIssueCodeBlocksComponentToText),
                new(addCqProjectMetricsHistory),
        }

Reply via email to