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

   <!-- Answer -->
   To resolve the "Data too long for column 'project_key'" error when running a 
Sonarcloud task, you need to expand the `ProjectKey` column size in the 
database. The provided migration script `expandProjectKey20230206` does exactly 
that by transforming the `ProjectKey` column from `varchar(64)` to 
`varchar(255)` in the `_tool_sonarqube_projects` table and from `varchar(100)` 
to `varchar(255)` in the `_tool_sonarqube_issues` table.
   
   Here is the relevant part of the migration script:
   
   ```go
   type expandProjectKey20230206 struct{}
   
   func (script *expandProjectKey20230206) Up(basicRes context.BasicRes) 
errors.Error {
        // expand `ProjectKey` from varchar(64) to varchar(255)
        err := migrationhelper.TransformTable(
                basicRes,
                script,
                "_tool_sonarqube_projects",
                func(s *SonarqubeProject20230206Before) 
(*SonarqubeProject20230206After, errors.Error) {
                        dst := (*SonarqubeProject20230206After)(s)
                        return dst, nil
                },
        )
        if err != nil {
                return err
        }
   
        // expand `ProjectKey` from varchar(100) to varchar(255)
        err = migrationhelper.TransformTable(
                basicRes,
                script,
                "_tool_sonarqube_issues",
                func(s *SonarqubeIssue20230206Before) 
(*SonarqubeIssue20230206After, errors.Error) {
                        dst := (*SonarqubeIssue20230206After)(s)
                        return dst, nil
                },
        )
        if err != nil {
                return err
        }
   
        // also, SonarqubeFileMetrics and SonarqubeHotspot have ProjectKey.
        // But I think varchar(191) in mysql and text in pg is enough.
        return nil
   }
   ```
   
   To apply this migration, ensure that the migration script is executed in 
your environment. This will update the column sizes and resolve the "Data too 
long for column 'project_key'" error 
<sup>[[1]](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/sonarqube/models/migrationscripts/20230321_expend_project_key.go)</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