This is an automated email from the ASF dual-hosted git repository. lynwee pushed a commit to branch dev-1 in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 74aa2fb85c951ffeddc42e59b88558ce15300d1c Author: d4x1 <[email protected]> AuthorDate: Tue Jul 9 11:51:23 2024 +0800 fix(sonarqube): update name field in sonar tool layer tables --- .../20240709_modify_name_length.go | 57 ++++++++++++++++++++++ .../sonarqube/models/migrationscripts/register.go | 1 + .../plugins/sonarqube/models/sonarqube_account.go | 2 +- .../plugins/sonarqube/models/sonarqube_project.go | 2 +- 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/backend/plugins/sonarqube/models/migrationscripts/20240709_modify_name_length.go b/backend/plugins/sonarqube/models/migrationscripts/20240709_modify_name_length.go new file mode 100644 index 000000000..146da425f --- /dev/null +++ b/backend/plugins/sonarqube/models/migrationscripts/20240709_modify_name_length.go @@ -0,0 +1,57 @@ +/* +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" + "github.com/apache/incubator-devlake/helpers/migrationhelper" +) + +var _ plugin.MigrationScript = (*modifyNameLength)(nil) + +type modifyNameLength struct{} + +type sonarqubeAccount20240709 struct { + Name string `gorm:"type:varchar(500)"` +} + +func (sonarqubeAccount20240709) TableName() string { + return "_tool_sonarqube_accounts" +} + +type sonarqubeProject20240709 struct { + Name string `json:"name" gorm:"type:varchar(500)" mapstructure:"name"` +} + +func (sonarqubeProject20240709) TableName() string { + return "_tool_sonarqube_projects" +} + +func (script *modifyNameLength) Up(basicRes context.BasicRes) errors.Error { + return migrationhelper.AutoMigrateTables(basicRes, &sonarqubeAccount20240709{}, &sonarqubeProject20240709{}) +} + +func (*modifyNameLength) Version() uint64 { + return 20240709114000 +} + +func (*modifyNameLength) Name() string { + return "modify name type to varchar(500)" +} diff --git a/backend/plugins/sonarqube/models/migrationscripts/register.go b/backend/plugins/sonarqube/models/migrationscripts/register.go index 4e6297c44..3f2181367 100644 --- a/backend/plugins/sonarqube/models/migrationscripts/register.go +++ b/backend/plugins/sonarqube/models/migrationscripts/register.go @@ -33,5 +33,6 @@ func All() []plugin.MigrationScript { new(modifyCommitCharacterType), new(modifyCommitCharacterType0508), new(updateSonarQubeScopeConfig20240614), + new(modifyNameLength), } } diff --git a/backend/plugins/sonarqube/models/sonarqube_account.go b/backend/plugins/sonarqube/models/sonarqube_account.go index c0d3850b1..8e3754532 100644 --- a/backend/plugins/sonarqube/models/sonarqube_account.go +++ b/backend/plugins/sonarqube/models/sonarqube_account.go @@ -25,7 +25,7 @@ type SonarqubeAccount struct { common.NoPKModel ConnectionId uint64 `gorm:"primaryKey"` Login string `json:"login" gorm:"primaryKey"` - Name string `gorm:"type:varchar(100)"` + Name string `gorm:"type:varchar(500)"` Email string `gorm:"type:varchar(100)"` Active bool `json:"active"` Local bool `json:"local"` diff --git a/backend/plugins/sonarqube/models/sonarqube_project.go b/backend/plugins/sonarqube/models/sonarqube_project.go index d99c437cc..b31e0214f 100644 --- a/backend/plugins/sonarqube/models/sonarqube_project.go +++ b/backend/plugins/sonarqube/models/sonarqube_project.go @@ -27,7 +27,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"` - Name string `json:"name" gorm:"type:varchar(255)" mapstructure:"name"` + 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"` LastAnalysisDate *common.Iso8601Time `json:"lastAnalysisDate" mapstructure:"lastAnalysisDate"`
