This is an automated email from the ASF dual-hosted git repository.

abeizn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 172b2183a202eb4ef253a469f2191f40d07e1289
Author: xgdyp <[email protected]>
AuthorDate: Tue Jul 19 16:46:54 2022 +0800

    fix: update migrationscript
---
 models/domainlayer/code/commit.go                | 16 ++++++++--------
 models/migrationscripts/updateSchemas20220711.go | 15 +++++++--------
 plugins/gitextractor/parser/repo.go              |  6 ++++--
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/models/domainlayer/code/commit.go 
b/models/domainlayer/code/commit.go
index 9b20cd3b..b48ef489 100644
--- a/models/domainlayer/code/commit.go
+++ b/models/domainlayer/code/commit.go
@@ -46,10 +46,11 @@ func (Commit) TableName() string {
 
 type CommitFile struct {
        common.NoPKModel
-       CommitSha string `gorm:"primaryKey;type:varchar(40)"`
-       FilePath  string `gorm:"primaryKey;type:varchar(255)"`
-       Additions int
-       Deletions int
+       CommitFileID string `gorm:"primaryKey;type:varchar(255)"`
+       CommitSha    string `gorm:"type:varchar(40)"`
+       FilePath     string `gorm:"type:varchar(255)"`
+       Additions    int
+       Deletions    int
 }
 
 func (CommitFile) TableName() string {
@@ -68,10 +69,9 @@ func (FileComponent) TableName() string {
 
 type CommitfileComponent struct {
        common.NoPKModel
-       RepoId    string `gorm:"primaryKey;type:varchar(255)"`
-       Component string `gorm:"type:varchar(255)"`
-       CommitSha string `gorm:"primaryKey;type:varchar(40)"`
-       FilePath  string `gorm:"primaryKey;type:varchar(255)"`
+       CommitFileID string `gorm:"primaryKey;type:varchar(255)"`
+       RepoId       string `gorm:"primaryKey;type:varchar(255)"`
+       Component    string `gorm:"type:varchar(255)"`
 }
 
 func (CommitfileComponent) TableName() string {
diff --git a/models/migrationscripts/updateSchemas20220711.go 
b/models/migrationscripts/updateSchemas20220711.go
index f2c3f499..ffbbe3d5 100644
--- a/models/migrationscripts/updateSchemas20220711.go
+++ b/models/migrationscripts/updateSchemas20220711.go
@@ -44,9 +44,9 @@ func (FileComponent) TableName() string {
 
 type CommitFile struct {
        common.NoPKModel
-       CommitFileID string `gorm:"primaryKey;"`
-       CommitSha    string `gorm:"primaryKey;type:varchar(40)"`
-       FilePath     string `gorm:"primaryKey;type:varchar(255)"`
+       CommitFileID string `gorm:"primaryKey;type:varchar(255)"`
+       CommitSha    string `gorm:"type:varchar(40)"`
+       FilePath     string `gorm:"type:varchar(255)"`
        Additions    int
        Deletions    int
        Component    string `gorm:"type:varchar(255)"`
@@ -58,10 +58,9 @@ func (CommitFile) TableName() string {
 
 type CommitfileComponent struct {
        common.NoPKModel
-       RepoId    string `gorm:"primaryKey;type:varchar(255)"`
-       Component string `gorm:"type:varchar(255)"`
-       CommitSha string `gorm:"primaryKey;type:varchar(40)"`
-       FilePath  string `gorm:"primaryKey;type:varchar(255)"`
+       CommitFileID string `gorm:"primaryKey;type:varchar(255)"`
+       RepoId       string `gorm:"primaryKey;type:varchar(255)"`
+       Component    string `gorm:"type:varchar(255)"`
 }
 
 func (CommitfileComponent) TableName() string {
@@ -81,7 +80,7 @@ func (*updateSchemas20220711) Up(ctx context.Context, db 
*gorm.DB) error {
 }
 
 func (*updateSchemas20220711) Version() uint64 {
-       return 20220711122544
+       return 202207151400
 }
 
 func (*updateSchemas20220711) Name() string {
diff --git a/plugins/gitextractor/parser/repo.go 
b/plugins/gitextractor/parser/repo.go
index 663bbfc5..8656a5e1 100644
--- a/plugins/gitextractor/parser/repo.go
+++ b/plugins/gitextractor/parser/repo.go
@@ -327,6 +327,7 @@ func (r *GitRepo) storeCommitFilesFromDiff(commitSha 
string, diff *git.Diff, com
                commitFile = new(code.CommitFile)
                commitFile.CommitSha = commitSha
                commitFile.FilePath = file.NewFile.Path
+               commitFile.CommitFileID = commitSha + ":" + file.NewFile.Path
                commitfileComponent = new(code.CommitfileComponent)
                for component, reg := range componentMap {
                        if reg.MatchString(commitFile.FilePath) {
@@ -335,8 +336,9 @@ func (r *GitRepo) storeCommitFilesFromDiff(commitSha 
string, diff *git.Diff, com
                        }
                }
                commitfileComponent.RepoId = r.id
-               commitfileComponent.FilePath = file.NewFile.Path
-               commitfileComponent.CommitSha = commitSha
+               commitfileComponent.CommitFileID = commitSha + ":" + 
file.NewFile.Path
+               //commitfileComponent.FilePath = file.NewFile.Path
+               //commitfileComponent.CommitSha = commitSha
                if commitfileComponent.Component == "" {
                        commitfileComponent.Component = "Default"
                }

Reply via email to