From 3f6f26fe72945c4f3612217af33f7a581781a3dd Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Thu, 24 Aug 2023 11:19:06 +0800 Subject: [PATCH 1/2] fix: remove deprecated BlueprintScopeV200.Entities --- backend/core/plugin/plugin_blueprint.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/backend/core/plugin/plugin_blueprint.go b/backend/core/plugin/plugin_blueprint.go index 68aa1c51cc8..e86379f5b81 100644 --- a/backend/core/plugin/plugin_blueprint.go +++ b/backend/core/plugin/plugin_blueprint.go @@ -87,8 +87,6 @@ type BlueprintConnectionV200 struct { type BlueprintScopeV200 struct { Id string `json:"id"` Name string `json:"name"` - // Deprecated: Entities is moved to the ScopeConfig struct - Entities []string `json:"entities"` } // MetricPluginBlueprintV200 is similar to the DataSourcePluginBlueprintV200 From 854060f1fb153390e6f87a552c3733ae758a14d0 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Thu, 24 Aug 2023 11:20:39 +0800 Subject: [PATCH 2/2] fix: missing migration logic in 20230612_add_fullName --- .../migrationscripts/20230612_add_fullName.go | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/backend/plugins/github/models/migrationscripts/20230612_add_fullName.go b/backend/plugins/github/models/migrationscripts/20230612_add_fullName.go index 447c1537c4d..6a1034b2378 100644 --- a/backend/plugins/github/models/migrationscripts/20230612_add_fullName.go +++ b/backend/plugins/github/models/migrationscripts/20230612_add_fullName.go @@ -18,12 +18,18 @@ limitations under the License. package migrationscripts import ( + "strings" + "github.com/apache/incubator-devlake/core/context" "github.com/apache/incubator-devlake/core/errors" + "github.com/apache/incubator-devlake/helpers/migrationhelper" ) type githubRepo20230612 struct { - FullName string `gorm:"type:varchar(255)"` + ConnectionId uint64 `gorm:"primaryKey"` + GithubId int `gorm:"primaryKey"` + Name string `gorm:"type:varchar(255)"` + FullName string `gorm:"type:varchar(255)"` } func (githubRepo20230612) TableName() string { @@ -33,12 +39,29 @@ func (githubRepo20230612) TableName() string { type addFullName struct{} func (*addFullName) Up(res context.BasicRes) errors.Error { + gr := &githubRepo20230612{} db := res.GetDal() - return db.AutoMigrate(&githubRepo20230612{}) + err := db.AutoMigrate(gr) + if err != nil { + return err + } + return migrationhelper.CopyTableColumns[githubRepo20230612, githubRepo20230612]( + res, + gr.TableName(), + gr.TableName(), + func(gr *githubRepo20230612) (*githubRepo20230612, errors.Error) { + fn := strings.Split(gr.Name, "/") + if len(fn) == 2 { + gr.FullName = gr.Name + gr.Name = fn[1] + } + return gr, nil + }, + ) } func (*addFullName) Version() uint64 { - return 20230612184110 + return 20230612184111 } func (*addFullName) Name() string {