Skip to content

Commit

Permalink
fix(sonarqube): update name field in sonar tool layer tables (#7707) (#…
Browse files Browse the repository at this point in the history
…7709)

Co-authored-by: Lynwee <linwei.hou@merico.dev>
  • Loading branch information
github-actions[bot] and d4x1 authored Jul 9, 2024
1 parent a7fbfd6 commit f589c27
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ func All() []plugin.MigrationScript {
new(modifyCommitCharacterType),
new(modifyCommitCharacterType0508),
new(updateSonarQubeScopeConfig20240614),
new(modifyNameLength),
}
}
2 changes: 1 addition & 1 deletion backend/plugins/sonarqube/models/sonarqube_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion backend/plugins/sonarqube/models/sonarqube_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit f589c27

Please sign in to comment.