dosubot[bot] commented on issue #7852: URL: https://github.com/apache/incubator-devlake/issues/7852#issuecomment-2272016847
<!-- Answer --> To resolve the "Data too long for column 'component' at row 12" error encountered during a SonarCube scan in the pipeline, you need to modify the length of the 'component' column in the relevant tables. The provided migration script `20231007_modify_component_length.go` shows how to change the column type to `varchar(500)`. Here is the relevant code snippet from the 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 modifies the `component` column type to `varchar(500)` for the following tables: - `_tool_sonarqube_hotspots` - `_tool_sonarqube_issue_code_blocks` - `_tool_sonarqube_issues` To apply this migration, ensure that the script is executed in your database migration process. This should resolve the "Data too long for column 'component' at row 12" error <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/docs/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