Skip to content

Commit 64c82ac

Browse files
github-actions[bot]Klesh Wong
andauthored
GitHub fails after upgrade to v0.18 (#5946) (#5947)
* fix: remove deprecated BlueprintScopeV200.Entities * fix: missing migration logic in 20230612_add_fullName Co-authored-by: Klesh Wong <zhenmian.huang@merico.dev>
1 parent 65f5ba6 commit 64c82ac

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

backend/core/plugin/plugin_blueprint.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ type BlueprintConnectionV200 struct {
8787
type BlueprintScopeV200 struct {
8888
Id string `json:"id"`
8989
Name string `json:"name"`
90-
// Deprecated: Entities is moved to the ScopeConfig struct
91-
Entities []string `json:"entities"`
9290
}
9391

9492
// MetricPluginBlueprintV200 is similar to the DataSourcePluginBlueprintV200

backend/plugins/github/models/migrationscripts/20230612_add_fullName.go

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ limitations under the License.
1818
package migrationscripts
1919

2020
import (
21+
"strings"
22+
2123
"github.com/apache/incubator-devlake/core/context"
2224
"github.com/apache/incubator-devlake/core/errors"
25+
"github.com/apache/incubator-devlake/helpers/migrationhelper"
2326
)
2427

2528
type githubRepo20230612 struct {
26-
FullName string `gorm:"type:varchar(255)"`
29+
ConnectionId uint64 `gorm:"primaryKey"`
30+
GithubId int `gorm:"primaryKey"`
31+
Name string `gorm:"type:varchar(255)"`
32+
FullName string `gorm:"type:varchar(255)"`
2733
}
2834

2935
func (githubRepo20230612) TableName() string {
@@ -33,12 +39,29 @@ func (githubRepo20230612) TableName() string {
3339
type addFullName struct{}
3440

3541
func (*addFullName) Up(res context.BasicRes) errors.Error {
42+
gr := &githubRepo20230612{}
3643
db := res.GetDal()
37-
return db.AutoMigrate(&githubRepo20230612{})
44+
err := db.AutoMigrate(gr)
45+
if err != nil {
46+
return err
47+
}
48+
return migrationhelper.CopyTableColumns[githubRepo20230612, githubRepo20230612](
49+
res,
50+
gr.TableName(),
51+
gr.TableName(),
52+
func(gr *githubRepo20230612) (*githubRepo20230612, errors.Error) {
53+
fn := strings.Split(gr.Name, "/")
54+
if len(fn) == 2 {
55+
gr.FullName = gr.Name
56+
gr.Name = fn[1]
57+
}
58+
return gr, nil
59+
},
60+
)
3861
}
3962

4063
func (*addFullName) Version() uint64 {
41-
return 20230612184110
64+
return 20230612184111
4265
}
4366

4467
func (*addFullName) Name() string {

0 commit comments

Comments
 (0)