You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2023/08/24 03:21:03 UTC
[incubator-devlake] 02/02: fix: missing migration logic in 20230612_add_fullName
This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch kw-5945-github-fail-after-upgrade-to-v0.18
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 854060f1fb153390e6f87a552c3733ae758a14d0
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Thu Aug 24 11:20:39 2023 +0800
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 447c1537c..6a1034b23 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 {