dosubot[bot] commented on issue #7586:
URL: 
https://github.com/apache/incubator-devlake/issues/7586#issuecomment-2154202763

   <!-- Greeting -->
   Hey @klemen-df! I'm here to help you with any bugs, questions, or 
contributions you have for the project. Let me know how I can assist you!
   
   <!-- Answer -->
   To resolve the error "Data too long for column 'component' at row 209" 
encountered during the SonarQube scraping process in version v1.0.0-beta10, you 
need to modify the length of the 'component' column in the relevant tables. The 
provided migration script `20231007_modify_component_length.go` changes the 
column type to `varchar(500)` for the `component` field in the 
`_tool_sonarqube_hotspots`, `_tool_sonarqube_issue_code_blocks`, and 
`_tool_sonarqube_issues` tables.
   
   Here is the relevant migration script:
   
   ```go
   package migrationscripts
   
   import (
        "github.com/apache/incubator-devlake/core/context"
        "github.com/apache/incubator-devlake/core/dal"
        "github.com/apache/incubator-devlake/core/errors"
        "github.com/apache/incubator-devlake/core/plugin"
        "github.com/apache/incubator-devlake/helpers/migrationhelper"
   )
   
   var _ plugin.MigrationScript = (*modifyComponentLength)(nil)
   
   type modifyComponentLength struct{}
   
   type sonarqubeHotspot20231007 struct {
        Component string `gorm:"index;type:varchar(500)"`
   }
   
   func (sonarqubeHotspot20231007) TableName() string {
        return "_tool_sonarqube_hotspots"
   }
   
   type sonarqubeIssueCodeBlock20231007 struct {
        Component string `gorm:"index;type:varchar(500)"`
   }
   
   func (sonarqubeIssueCodeBlock20231007) TableName() string {
        return "_tool_sonarqube_issue_code_blocks"
   }
   
   type sonarqubeIssue20231007 struct {
        Component string `gorm:"index;type:varchar(500)"`
   }
   
   func (sonarqubeIssue20231007) TableName() string {
        return "_tool_sonarqube_issues"
   }
   
   func (script *modifyComponentLength) Up(basicRes context.BasicRes) 
errors.Error {
        db := basicRes.GetDal()
        err := migrationhelper.ChangeColumnsType[sonarqubeHotspot20231007](
                basicRes,
                script,
                sonarqubeHotspot20231007{}.TableName(),
                []string{"component"},
                func(tmpColumnParams []interface{}) errors.Error {
                        return db.UpdateColumn(
                                &sonarqubeHotspot20231007{},
                                "component",
                                dal.DalClause{Expr: " ? ", Params: 
tmpColumnParams},
                                dal.Where("? != '' ", tmpColumnParams...),
                        )
                },
        )
        if err != nil {
                return err
        }
   
        err = 
migrationhelper.ChangeColumnsType[sonarqubeIssueCodeBlock20231007](
                basicRes,
                script,
                sonarqubeIssueCodeBlock20231007{}.TableName(),
                []string{"component"},
                func(tmpColumnParams []interface{}) errors.Error {
                        return db.UpdateColumn(
                                &sonarqubeIssueCodeBlock20231007{},
                                "component",
                                dal.DalClause{Expr: " ? ", Params: 
tmpColumnParams},
                                dal.Where("? != '' ", tmpColumnParams...),
                        )
                },
        )
        if err != nil {
                return err
        }
   
        err = migrationhelper.ChangeColumnsType[sonarqubeIssue20231007](
                basicRes,
                script,
                sonarqubeIssue20231007{}.TableName(),
                []string{"component"},
                func(tmpColumnParams []interface{}) errors.Error {
                        return db.UpdateColumn(
                                &sonarqubeIssue20231007{},
                                "component",
                                dal.DalClause{Expr: " ? ", Params: 
tmpColumnParams},
                                dal.Where("? != '' ", tmpColumnParams...),
                        )
                },
        )
        if err != nil {
                return err
        }
   
        return nil
   }
   
   func (*modifyComponentLength) Version() uint64 {
        return 20231007145127
   }
   
   func (*modifyComponentLength) Name() string {
        return "modify component type to varchar(500)"
   }
   ```
   
   This script increases the length of the `component` column to 500 
characters, which should resolve the "Data too long for column 'component'" 
error. Additionally, if you encounter similar issues with other columns or 
tables, you can refer to the [Configuration and Blueprint 
Troubleshooting](https://github.com/apache/incubator-devlake/issues/4053) 
documentation for more detailed solutions and workarounds 
<sup>[[1]](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/sonarqube/models/migrationscripts/20231007_modify_component_length.go)</sup><sup>[[2]](https://github.com/apache/incubator-devlake-website/blob/main/versioned_docs/version-v1.0/Troubleshooting/Configuration.md)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@devlake.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to