diff --git a/backend/core/dal/dal.go b/backend/core/dal/dal.go index 48cc3601061..d5f4fbfeafb 100644 --- a/backend/core/dal/dal.go +++ b/backend/core/dal/dal.go @@ -167,6 +167,8 @@ type Dal interface { GetPrimaryKeyFields(t reflect.Type) []reflect.StructField // RenameColumn renames column name for specified table RenameColumn(table, oldColumnName, newColumnName string) errors.Error + // ModifyColumnType modifies column type + ModifyColumnType(table, columnName, columnType string) errors.Error // DropIndexes drops all specified tables DropIndexes(table string, indexes ...string) errors.Error // Dialect returns the dialect of current database diff --git a/backend/core/models/domainlayer/codequality/cq_projects.go b/backend/core/models/domainlayer/codequality/cq_projects.go index 5ba5d11b23b..fe80dd1bb5b 100644 --- a/backend/core/models/domainlayer/codequality/cq_projects.go +++ b/backend/core/models/domainlayer/codequality/cq_projects.go @@ -26,7 +26,7 @@ import ( var _ plugin.Scope = (*CqProject)(nil) type CqProject struct { - domainlayer.DomainEntity + domainlayer.DomainEntityExtended Name string `gorm:"type:varchar(255)"` Qualifier string `gorm:"type:varchar(255)"` Visibility string `gorm:"type:varchar(64)"` diff --git a/backend/core/models/domainlayer/ticket/issue.go b/backend/core/models/domainlayer/ticket/issue.go index 278b2f8253b..f7d5cc562ef 100644 --- a/backend/core/models/domainlayer/ticket/issue.go +++ b/backend/core/models/domainlayer/ticket/issue.go @@ -51,7 +51,7 @@ type Issue struct { Priority string `gorm:"type:varchar(255)"` Severity string `gorm:"type:varchar(255)"` Urgency string `gorm:"type:varchar(255)"` - Component string `gorm:"type:varchar(255)"` + Component string `gorm:"type:text"` OriginalProject string `gorm:"type:varchar(255)"` IsSubtask bool } diff --git a/backend/core/models/migrationscripts/20240813_change_issue_component_type.go b/backend/core/models/migrationscripts/20240813_change_issue_component_type.go new file mode 100644 index 00000000000..8f7a2f2fe8a --- /dev/null +++ b/backend/core/models/migrationscripts/20240813_change_issue_component_type.go @@ -0,0 +1,40 @@ +/* +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 = (*changeIssueComponentType)(nil) + +type changeIssueComponentType struct{} + +func (script *changeIssueComponentType) Up(basicRes context.BasicRes) errors.Error { + return basicRes.GetDal().ModifyColumnType("issues", "components", "text") +} + +func (*changeIssueComponentType) Version() uint64 { + return 20240813153901 +} + +func (*changeIssueComponentType) Name() string { + return "change issues.components type to text" +} diff --git a/backend/core/models/migrationscripts/20240813_increase_project_key_length.go b/backend/core/models/migrationscripts/20240813_increase_project_key_length.go new file mode 100644 index 00000000000..609b3d7364b --- /dev/null +++ b/backend/core/models/migrationscripts/20240813_increase_project_key_length.go @@ -0,0 +1,40 @@ +/* +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 = (*increaseProjectKeyLength)(nil) + +type increaseProjectKeyLength struct{} + +func (script *increaseProjectKeyLength) Up(basicRes context.BasicRes) errors.Error { + return basicRes.GetDal().ModifyColumnType("cq_projects", "project_key", "varchar(500)") +} + +func (*increaseProjectKeyLength) Version() uint64 { + return 20240813160242 +} + +func (*increaseProjectKeyLength) Name() string { + return "increase cq_projects.project_key length to 500" +} diff --git a/backend/impls/dalgorm/dalgorm.go b/backend/impls/dalgorm/dalgorm.go index ba3bcdb6181..59e6b115f6b 100644 --- a/backend/impls/dalgorm/dalgorm.go +++ b/backend/impls/dalgorm/dalgorm.go @@ -372,6 +372,24 @@ func (d *Dalgorm) RenameColumn(table, oldColumnName, newColumnName string) error ) } +// ModifyColumnType modify column type +func (d *Dalgorm) ModifyColumnType(table, columnName, columnType string) errors.Error { + // work around the error `cached plan must not change result type` for postgres + // wrap in func(){} to make the linter happy + defer func() { + _ = d.Exec("SELECT * FROM ? LIMIT 1", clause.Table{Name: table}) + }() + query := "ALTER TABLE ? MODIFY COLUMN ? %s" + if d.db.Dialector.Name() == "postgres" { + query = "ALTER TABLE ? ALTER COLUMN ? TYPE %s" + } + return d.Exec( + fmt.Sprintf(query, columnType), + clause.Table{Name: table}, + clause.Column{Name: columnName}, + ) +} + // AllTables returns all tables in the database func (d *Dalgorm) AllTables() ([]string, errors.Error) { var tableSql string diff --git a/backend/plugins/bitbucket/models/issue.go b/backend/plugins/bitbucket/models/issue.go index c4f0d20fbb2..c24fbf1e89e 100644 --- a/backend/plugins/bitbucket/models/issue.go +++ b/backend/plugins/bitbucket/models/issue.go @@ -45,7 +45,7 @@ type BitbucketIssue struct { BitbucketCreatedAt time.Time BitbucketUpdatedAt time.Time `gorm:"index"` Severity string `gorm:"type:varchar(255)"` - Component string `gorm:"type:varchar(255)"` + Component string `gorm:"type:text"` common.NoPKModel } diff --git a/backend/plugins/bitbucket/models/migrationscripts/20240813_change_issue_component_type.go b/backend/plugins/bitbucket/models/migrationscripts/20240813_change_issue_component_type.go new file mode 100644 index 00000000000..0499d0ac234 --- /dev/null +++ b/backend/plugins/bitbucket/models/migrationscripts/20240813_change_issue_component_type.go @@ -0,0 +1,40 @@ +/* +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 = (*changeIssueComponentType)(nil) + +type changeIssueComponentType struct{} + +func (script *changeIssueComponentType) Up(basicRes context.BasicRes) errors.Error { + return basicRes.GetDal().ModifyColumnType("_tool_bitbucket_issues", "components", "text") +} + +func (*changeIssueComponentType) Version() uint64 { + return 20240813154323 +} + +func (*changeIssueComponentType) Name() string { + return "change _tool_bitbucket_issues.components type to text" +} diff --git a/backend/plugins/bitbucket/models/migrationscripts/register.go b/backend/plugins/bitbucket/models/migrationscripts/register.go index a197be73580..105af236446 100644 --- a/backend/plugins/bitbucket/models/migrationscripts/register.go +++ b/backend/plugins/bitbucket/models/migrationscripts/register.go @@ -41,5 +41,6 @@ func All() []plugin.MigrationScript { new(addBuildNumberToPipelines), new(reCreatBitBucketPipelineSteps), new(addMergedByToPr), + new(changeIssueComponentType), } } diff --git a/backend/plugins/gitee/models/issue.go b/backend/plugins/gitee/models/issue.go index 0753f46f1d3..60211dcf9fe 100644 --- a/backend/plugins/gitee/models/issue.go +++ b/backend/plugins/gitee/models/issue.go @@ -44,7 +44,7 @@ type GiteeIssue struct { GiteeCreatedAt time.Time GiteeUpdatedAt time.Time `gorm:"index"` Severity string `gorm:"type:varchar(255)"` - Component string `gorm:"type:varchar(255)"` + Component string `gorm:"type:text"` common.NoPKModel } diff --git a/backend/plugins/gitee/models/migrationscripts/20240813_change_issue_component_type.go b/backend/plugins/gitee/models/migrationscripts/20240813_change_issue_component_type.go new file mode 100644 index 00000000000..a669a31dd89 --- /dev/null +++ b/backend/plugins/gitee/models/migrationscripts/20240813_change_issue_component_type.go @@ -0,0 +1,40 @@ +/* +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 = (*changeIssueComponentType)(nil) + +type changeIssueComponentType struct{} + +func (script *changeIssueComponentType) Up(basicRes context.BasicRes) errors.Error { + return basicRes.GetDal().ModifyColumnType("_tool_gitee_issues", "components", "text") +} + +func (*changeIssueComponentType) Version() uint64 { + return 20240813154445 +} + +func (*changeIssueComponentType) Name() string { + return "change _tool_gitee_issues.components type to text" +} diff --git a/backend/plugins/gitee/models/migrationscripts/register.go b/backend/plugins/gitee/models/migrationscripts/register.go index 5e5ec138806..e089a9beccc 100644 --- a/backend/plugins/gitee/models/migrationscripts/register.go +++ b/backend/plugins/gitee/models/migrationscripts/register.go @@ -27,5 +27,6 @@ func All() []plugin.MigrationScript { new(addInitTables), new(addGiteeCommitAuthorInfo), new(addScopeConfigIdToRepo), + new(changeIssueComponentType), } } diff --git a/backend/plugins/github/models/issue.go b/backend/plugins/github/models/issue.go index 80e071cc54c..004e89a28ce 100644 --- a/backend/plugins/github/models/issue.go +++ b/backend/plugins/github/models/issue.go @@ -45,7 +45,7 @@ type GithubIssue struct { GithubCreatedAt time.Time GithubUpdatedAt time.Time `gorm:"index"` Severity string `gorm:"type:varchar(255)"` - Component string `gorm:"type:varchar(255)"` + Component string `gorm:"type:text"` common.NoPKModel } diff --git a/backend/plugins/github/models/migrationscripts/20240813_change_issue_component_type.go b/backend/plugins/github/models/migrationscripts/20240813_change_issue_component_type.go new file mode 100644 index 00000000000..be5a3be1293 --- /dev/null +++ b/backend/plugins/github/models/migrationscripts/20240813_change_issue_component_type.go @@ -0,0 +1,40 @@ +/* +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 = (*changeIssueComponentType)(nil) + +type changeIssueComponentType struct{} + +func (script *changeIssueComponentType) Up(basicRes context.BasicRes) errors.Error { + return basicRes.GetDal().ModifyColumnType("_tool_github_issues", "components", "text") +} + +func (*changeIssueComponentType) Version() uint64 { + return 20240813154633 +} + +func (*changeIssueComponentType) Name() string { + return "change _tool_github_issues.components type to text" +} diff --git a/backend/plugins/github/models/migrationscripts/register.go b/backend/plugins/github/models/migrationscripts/register.go index fec8b533847..346654d99fa 100644 --- a/backend/plugins/github/models/migrationscripts/register.go +++ b/backend/plugins/github/models/migrationscripts/register.go @@ -53,5 +53,6 @@ func All() []plugin.MigrationScript { new(addMergedByToPr), new(restructReviewer), new(addIsDraftToPr), + new(changeIssueComponentType), } } diff --git a/backend/plugins/gitlab/models/issue.go b/backend/plugins/gitlab/models/issue.go index 5d57d680617..36d66b5cd34 100644 --- a/backend/plugins/gitlab/models/issue.go +++ b/backend/plugins/gitlab/models/issue.go @@ -45,7 +45,7 @@ type GitlabIssue struct { GitlabCreatedAt time.Time GitlabUpdatedAt time.Time `gorm:"index"` Severity string `gorm:"type:varchar(255)"` - Component string `gorm:"type:varchar(255)"` + Component string `gorm:"type:text"` TimeEstimate *int64 TotalTimeSpent *int64 common.NoPKModel diff --git a/backend/plugins/gitlab/models/migrationscripts/20240813_change_issue_component_type.go b/backend/plugins/gitlab/models/migrationscripts/20240813_change_issue_component_type.go new file mode 100644 index 00000000000..08c88ac294e --- /dev/null +++ b/backend/plugins/gitlab/models/migrationscripts/20240813_change_issue_component_type.go @@ -0,0 +1,40 @@ +/* +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 = (*changeIssueComponentType)(nil) + +type changeIssueComponentType struct{} + +func (script *changeIssueComponentType) Up(basicRes context.BasicRes) errors.Error { + return basicRes.GetDal().ModifyColumnType("_tool_gitlab_issues", "components", "text") +} + +func (*changeIssueComponentType) Version() uint64 { + return 20240813154323 +} + +func (*changeIssueComponentType) Name() string { + return "change _tool_gitlab_issues.components type to text" +} diff --git a/backend/plugins/gitlab/models/migrationscripts/register.go b/backend/plugins/gitlab/models/migrationscripts/register.go index 24af299b0fb..8fda16c47f1 100644 --- a/backend/plugins/gitlab/models/migrationscripts/register.go +++ b/backend/plugins/gitlab/models/migrationscripts/register.go @@ -50,5 +50,6 @@ func All() []plugin.MigrationScript { new(addWebUrlToGitlabPipelineProject), new(addGitlabAssignee), new(addGitlabAssigneeAndReviewerPrimaryKey), + new(changeIssueComponentType), } } diff --git a/backend/plugins/jira/models/issue.go b/backend/plugins/jira/models/issue.go index 0b629449055..12db2b00bde 100644 --- a/backend/plugins/jira/models/issue.go +++ b/backend/plugins/jira/models/issue.go @@ -62,7 +62,7 @@ type JiraIssue struct { LeadTimeMinutes *uint StdType string `gorm:"type:varchar(255)"` StdStatus string `gorm:"type:varchar(255)"` - Components string `gorm:"type:varchar(255)"` + Components string `gorm:"type:text"` Subtask bool ChangelogTotal int WorklogTotal int diff --git a/backend/plugins/jira/models/migrationscripts/20240809_change_issue_component_type.go b/backend/plugins/jira/models/migrationscripts/20240809_change_issue_component_type.go new file mode 100644 index 00000000000..30329085c34 --- /dev/null +++ b/backend/plugins/jira/models/migrationscripts/20240809_change_issue_component_type.go @@ -0,0 +1,40 @@ +/* +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 = (*changeIssueComponentType)(nil) + +type changeIssueComponentType struct{} + +func (script *changeIssueComponentType) Up(basicRes context.BasicRes) errors.Error { + return basicRes.GetDal().ModifyColumnType("_tool_jira_issues", "components", "text") +} + +func (*changeIssueComponentType) Version() uint64 { + return 20240809165545 +} + +func (*changeIssueComponentType) Name() string { + return "change jira_issue.components type to text" +} diff --git a/backend/plugins/jira/models/migrationscripts/register.go b/backend/plugins/jira/models/migrationscripts/register.go index f2764ef4223..6b7b89f84a6 100644 --- a/backend/plugins/jira/models/migrationscripts/register.go +++ b/backend/plugins/jira/models/migrationscripts/register.go @@ -51,5 +51,6 @@ func All() []plugin.MigrationScript { new(addSubtaskToIssue), new(addTmpAccountIdToJiraIssueChangelogItem), new(addIssueFieldTable), + new(changeIssueComponentType), } } diff --git a/backend/plugins/sonarqube/api/blueprint_v200.go b/backend/plugins/sonarqube/api/blueprint_v200.go index 250b1bf1db8..e4804534b5d 100644 --- a/backend/plugins/sonarqube/api/blueprint_v200.go +++ b/backend/plugins/sonarqube/api/blueprint_v200.go @@ -111,7 +111,7 @@ func makeScopesV200( sonarqubeProject := scopeDetail.Scope // add board to scopes domainBoard := &codequality.CqProject{ - DomainEntity: domainlayer.DomainEntity{ + DomainEntityExtended: domainlayer.DomainEntityExtended{ Id: didgen.NewDomainIdGenerator(&models.SonarqubeProject{}).Generate(sonarqubeProject.ConnectionId, sonarqubeProject.ProjectKey), }, Name: sonarqubeProject.Name, diff --git a/backend/plugins/sonarqube/models/migrationscripts/20240813_change_issue_component_type.go b/backend/plugins/sonarqube/models/migrationscripts/20240813_change_issue_component_type.go new file mode 100644 index 00000000000..eb7e713c834 --- /dev/null +++ b/backend/plugins/sonarqube/models/migrationscripts/20240813_change_issue_component_type.go @@ -0,0 +1,40 @@ +/* +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 = (*changeIssueComponentType)(nil) + +type changeIssueComponentType struct{} + +func (script *changeIssueComponentType) Up(basicRes context.BasicRes) errors.Error { + return basicRes.GetDal().ModifyColumnType("_tool_sonarqube_issues", "components", "text") +} + +func (*changeIssueComponentType) Version() uint64 { + return 20240813153541 +} + +func (*changeIssueComponentType) Name() string { + return "change _tool_sonarqube_issues.components type to text" +} diff --git a/backend/plugins/sonarqube/models/migrationscripts/20240813_increase_project_key_length.go b/backend/plugins/sonarqube/models/migrationscripts/20240813_increase_project_key_length.go new file mode 100644 index 00000000000..ed198167083 --- /dev/null +++ b/backend/plugins/sonarqube/models/migrationscripts/20240813_increase_project_key_length.go @@ -0,0 +1,40 @@ +/* +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 = (*increaseProjectKeyLength)(nil) + +type increaseProjectKeyLength struct{} + +func (script *increaseProjectKeyLength) Up(basicRes context.BasicRes) errors.Error { + return basicRes.GetDal().ModifyColumnType("_tool_sonarqube_projects", "project_key", "varchar(500)") +} + +func (*increaseProjectKeyLength) Version() uint64 { + return 20240813155602 +} + +func (*increaseProjectKeyLength) Name() string { + return "increase _tool_sonarqube_projects.project_key length to 500" +} diff --git a/backend/plugins/sonarqube/models/migrationscripts/register.go b/backend/plugins/sonarqube/models/migrationscripts/register.go index 3f2181367c0..b11549cb8d5 100644 --- a/backend/plugins/sonarqube/models/migrationscripts/register.go +++ b/backend/plugins/sonarqube/models/migrationscripts/register.go @@ -34,5 +34,7 @@ func All() []plugin.MigrationScript { new(modifyCommitCharacterType0508), new(updateSonarQubeScopeConfig20240614), new(modifyNameLength), + new(changeIssueComponentType), + new(increaseProjectKeyLength), } } diff --git a/backend/plugins/sonarqube/models/sonarqube_issue.go b/backend/plugins/sonarqube/models/sonarqube_issue.go index 3bc8a2b1354..fefd75721f1 100644 --- a/backend/plugins/sonarqube/models/sonarqube_issue.go +++ b/backend/plugins/sonarqube/models/sonarqube_issue.go @@ -26,7 +26,7 @@ type SonarqubeIssue struct { IssueKey string `gorm:"primaryKey;type:varchar(100)"` Rule string `gorm:"type:varchar(255)"` Severity string `gorm:"type:varchar(100)"` - Component string `gorm:"type:varchar(500)"` + Component string `gorm:"type:text"` ProjectKey string `gorm:"index;type:varchar(255)"` //domain project key Line int Status string `gorm:"type:varchar(20)"` diff --git a/backend/plugins/sonarqube/models/sonarqube_project.go b/backend/plugins/sonarqube/models/sonarqube_project.go index b31e0214f3c..aeb57134b1f 100644 --- a/backend/plugins/sonarqube/models/sonarqube_project.go +++ b/backend/plugins/sonarqube/models/sonarqube_project.go @@ -26,7 +26,7 @@ var _ plugin.ToolLayerScope = (*SonarqubeProject)(nil) type SonarqubeProject struct { common.Scope `mapstructure:",squash"` - ProjectKey string `json:"projectKey" validate:"required" gorm:"type:varchar(255);primaryKey" mapstructure:"projectKey"` + ProjectKey string `json:"projectKey" validate:"required" gorm:"type:varchar(500);primaryKey" mapstructure:"projectKey"` Name string `json:"name" gorm:"type:varchar(500)" mapstructure:"name"` Qualifier string `json:"qualifier" gorm:"type:varchar(255)" mapstructure:"qualifier"` Visibility string `json:"visibility" gorm:"type:varchar(64)" mapstructure:"visibility"` diff --git a/backend/plugins/sonarqube/tasks/projects_convertor.go b/backend/plugins/sonarqube/tasks/projects_convertor.go index afa6a694d8a..3e3c1ebba2d 100644 --- a/backend/plugins/sonarqube/tasks/projects_convertor.go +++ b/backend/plugins/sonarqube/tasks/projects_convertor.go @@ -58,12 +58,12 @@ func ConvertProjects(taskCtx plugin.SubTaskContext) errors.Error { Convert: func(inputRow interface{}) ([]interface{}, errors.Error) { sonarqubeProject := inputRow.(*sonarqubeModels.SonarqubeProject) domainProject := &codequality.CqProject{ - DomainEntity: domainlayer.DomainEntity{Id: projectIdGen.Generate(data.Options.ConnectionId, sonarqubeProject.ProjectKey)}, - Name: sonarqubeProject.Name, - Qualifier: sonarqubeProject.Qualifier, - Visibility: sonarqubeProject.Visibility, - LastAnalysisDate: sonarqubeProject.LastAnalysisDate, - CommitSha: sonarqubeProject.Revision, + DomainEntityExtended: domainlayer.DomainEntityExtended{Id: projectIdGen.Generate(data.Options.ConnectionId, sonarqubeProject.ProjectKey)}, + Name: sonarqubeProject.Name, + Qualifier: sonarqubeProject.Qualifier, + Visibility: sonarqubeProject.Visibility, + LastAnalysisDate: sonarqubeProject.LastAnalysisDate, + CommitSha: sonarqubeProject.Revision, } return []interface{}{ domainProject,