You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2022/10/19 11:59:49 UTC

[incubator-devlake] branch main updated (af400b11 -> a9c2cc8f)

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

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


    from af400b11 fix: remove required in PrepareTaskData
     new 271059fd fix: some tables don't exist when devlake run in a new database
     new a9c2cc8f fix: some tables don't exist when devlake run in a new database

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 impl/dalgorm/dalgorm.go                              | 2 +-
 models/migrationscripts/20220904_encrypt_pipeline.go | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)


[incubator-devlake] 02/02: fix: some tables don't exist when devlake run in a new database

Posted by ab...@apache.org.
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 a9c2cc8f270940924e73aed8874a9a8aa8bdefb6
Author: abeizn <zi...@merico.dev>
AuthorDate: Wed Oct 19 19:36:20 2022 +0800

    fix: some tables don't exist when devlake run in a new database
---
 impl/dalgorm/dalgorm.go                                      |  2 +-
 models/migrationscripts/20220903_encrypt_blueprint.go        |  8 --------
 models/migrationscripts/20220904_encrypt_pipeline.go         |  8 --------
 .../migrationscripts/20220913_fix_commitfile_id_toolong.go   | 12 ------------
 .../jira/models/migrationscripts/20220716_add_init_tables.go |  8 --------
 5 files changed, 1 insertion(+), 37 deletions(-)

diff --git a/impl/dalgorm/dalgorm.go b/impl/dalgorm/dalgorm.go
index 1ffb3e27..502017a2 100644
--- a/impl/dalgorm/dalgorm.go
+++ b/impl/dalgorm/dalgorm.go
@@ -84,7 +84,7 @@ func (d *Dalgorm) AutoMigrate(entity interface{}, clauses ...dal.Clause) errors.
 	err := errors.Convert(buildTx(d.db, clauses).AutoMigrate(entity))
 	if err == nil {
 		// fix pg cache plan error
-		_ = d.db.Limit(1).Find(entity)
+		_ = d.First(entity, clauses...)
 	}
 	return err
 }
diff --git a/models/migrationscripts/20220903_encrypt_blueprint.go b/models/migrationscripts/20220903_encrypt_blueprint.go
index 7235ace8..c5171bc1 100644
--- a/models/migrationscripts/20220903_encrypt_blueprint.go
+++ b/models/migrationscripts/20220903_encrypt_blueprint.go
@@ -41,10 +41,6 @@ type Blueprint20220903Before struct {
 	archived.Model `swaggerignore:"true"`
 }
 
-func (Blueprint20220903Before) TableName() string {
-	return "_devlake_blueprints"
-}
-
 type Blueprint20220903After struct {
 	/* unchanged part */
 	Name           string `json:"name" validate:"required"`
@@ -58,10 +54,6 @@ type Blueprint20220903After struct {
 	Settings string `json:"settings"`
 }
 
-func (Blueprint20220903After) TableName() string {
-	return "_devlake_blueprints"
-}
-
 func (script *encryptBlueprint) Up(basicRes core.BasicRes) errors.Error {
 	encKey := basicRes.GetConfig(core.EncodeKeyEnvStr)
 	if encKey == "" {
diff --git a/models/migrationscripts/20220904_encrypt_pipeline.go b/models/migrationscripts/20220904_encrypt_pipeline.go
index 46c0713e..9f64dd86 100644
--- a/models/migrationscripts/20220904_encrypt_pipeline.go
+++ b/models/migrationscripts/20220904_encrypt_pipeline.go
@@ -47,10 +47,6 @@ type Pipeline20220904Before struct {
 	Stage         int            `json:"stage"`
 }
 
-func (Pipeline20220904Before) TableName() string {
-	return "_devlake_pipelines"
-}
-
 type Pipeline0904After struct {
 	common.Model
 	Name          string     `json:"name" gorm:"index"`
@@ -66,10 +62,6 @@ type Pipeline0904After struct {
 	Stage         int        `json:"stage"`
 }
 
-func (Pipeline0904After) TableName() string {
-	return "_devlake_pipelines"
-}
-
 func (script *encryptPipeline) Up(basicRes core.BasicRes) errors.Error {
 	encKey := basicRes.GetConfig(core.EncodeKeyEnvStr)
 	if encKey == "" {
diff --git a/models/migrationscripts/20220913_fix_commitfile_id_toolong.go b/models/migrationscripts/20220913_fix_commitfile_id_toolong.go
index 904fa746..7374d269 100644
--- a/models/migrationscripts/20220913_fix_commitfile_id_toolong.go
+++ b/models/migrationscripts/20220913_fix_commitfile_id_toolong.go
@@ -38,30 +38,18 @@ type commitFile20220913Before struct {
 	FilePath  string `gorm:"type:varchar(255)"` // target field
 }
 
-func (commitFile20220913Before) TableName() string {
-	return "commit_files"
-}
-
 type commitFile20220913After struct {
 	archived.DomainEntity
 	CommitSha string `gorm:"type:varchar(40)"`
 	FilePath  string `gorm:"type:text"` // target field
 }
 
-func (commitFile20220913After) TableName() string {
-	return "commit_files"
-}
-
 type commitFileComponent20220913 struct {
 	archived.NoPKModel
 	CommitFileId  string `gorm:"primaryKey;type:varchar(255)"`
 	ComponentName string `gorm:"type:varchar(255)"`
 }
 
-func (commitFileComponent20220913) TableName() string {
-	return "commit_file_components"
-}
-
 func (script *fixCommitFileIdTooLong) Up(basicRes core.BasicRes) errors.Error {
 	// To recalculate the primary key values for the `commit_files` since
 	// we used the `FilePath` as part of the primary key which would exceed
diff --git a/plugins/jira/models/migrationscripts/20220716_add_init_tables.go b/plugins/jira/models/migrationscripts/20220716_add_init_tables.go
index cee22c6f..87445a22 100644
--- a/plugins/jira/models/migrationscripts/20220716_add_init_tables.go
+++ b/plugins/jira/models/migrationscripts/20220716_add_init_tables.go
@@ -34,10 +34,6 @@ type jiraConnection20220716After struct {
 	archived.BasicAuth      `mapstructure:",squash"`
 }
 
-func (jiraConnection20220716After) TableName() string {
-	return "_tool_jira_connections"
-}
-
 type jiraConnection20220716Before struct {
 	ID                         uint64    `gorm:"primaryKey" json:"id"`
 	CreatedAt                  time.Time `json:"createdAt"`
@@ -52,10 +48,6 @@ type jiraConnection20220716Before struct {
 	RateLimit                  int       `comment:"api request rate limt per hour" json:"rateLimit"`
 }
 
-func (jiraConnection20220716Before) TableName() string {
-	return "_tool_jira_connections"
-}
-
 type addInitTables20220716 struct{}
 
 func (script *addInitTables20220716) Up(basicRes core.BasicRes) errors.Error {


[incubator-devlake] 01/02: fix: some tables don't exist when devlake run in a new database

Posted by ab...@apache.org.
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 271059fd50250ba29e35d080749075088562adf3
Author: abeizn <zi...@merico.dev>
AuthorDate: Wed Oct 19 18:17:02 2022 +0800

    fix: some tables don't exist when devlake run in a new database
---
 models/migrationscripts/20220903_encrypt_blueprint.go        |  8 ++++++++
 models/migrationscripts/20220904_encrypt_pipeline.go         |  6 +++++-
 .../migrationscripts/20220913_fix_commitfile_id_toolong.go   | 12 ++++++++++++
 .../jira/models/migrationscripts/20220716_add_init_tables.go |  8 ++++++++
 4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/models/migrationscripts/20220903_encrypt_blueprint.go b/models/migrationscripts/20220903_encrypt_blueprint.go
index c5171bc1..7235ace8 100644
--- a/models/migrationscripts/20220903_encrypt_blueprint.go
+++ b/models/migrationscripts/20220903_encrypt_blueprint.go
@@ -41,6 +41,10 @@ type Blueprint20220903Before struct {
 	archived.Model `swaggerignore:"true"`
 }
 
+func (Blueprint20220903Before) TableName() string {
+	return "_devlake_blueprints"
+}
+
 type Blueprint20220903After struct {
 	/* unchanged part */
 	Name           string `json:"name" validate:"required"`
@@ -54,6 +58,10 @@ type Blueprint20220903After struct {
 	Settings string `json:"settings"`
 }
 
+func (Blueprint20220903After) TableName() string {
+	return "_devlake_blueprints"
+}
+
 func (script *encryptBlueprint) Up(basicRes core.BasicRes) errors.Error {
 	encKey := basicRes.GetConfig(core.EncodeKeyEnvStr)
 	if encKey == "" {
diff --git a/models/migrationscripts/20220904_encrypt_pipeline.go b/models/migrationscripts/20220904_encrypt_pipeline.go
index d90ac70b..46c0713e 100644
--- a/models/migrationscripts/20220904_encrypt_pipeline.go
+++ b/models/migrationscripts/20220904_encrypt_pipeline.go
@@ -47,6 +47,10 @@ type Pipeline20220904Before struct {
 	Stage         int            `json:"stage"`
 }
 
+func (Pipeline20220904Before) TableName() string {
+	return "_devlake_pipelines"
+}
+
 type Pipeline0904After struct {
 	common.Model
 	Name          string     `json:"name" gorm:"index"`
@@ -62,7 +66,7 @@ type Pipeline0904After struct {
 	Stage         int        `json:"stage"`
 }
 
-func (Pipeline20220904Before) TableName() string {
+func (Pipeline0904After) TableName() string {
 	return "_devlake_pipelines"
 }
 
diff --git a/models/migrationscripts/20220913_fix_commitfile_id_toolong.go b/models/migrationscripts/20220913_fix_commitfile_id_toolong.go
index 7374d269..904fa746 100644
--- a/models/migrationscripts/20220913_fix_commitfile_id_toolong.go
+++ b/models/migrationscripts/20220913_fix_commitfile_id_toolong.go
@@ -38,18 +38,30 @@ type commitFile20220913Before struct {
 	FilePath  string `gorm:"type:varchar(255)"` // target field
 }
 
+func (commitFile20220913Before) TableName() string {
+	return "commit_files"
+}
+
 type commitFile20220913After struct {
 	archived.DomainEntity
 	CommitSha string `gorm:"type:varchar(40)"`
 	FilePath  string `gorm:"type:text"` // target field
 }
 
+func (commitFile20220913After) TableName() string {
+	return "commit_files"
+}
+
 type commitFileComponent20220913 struct {
 	archived.NoPKModel
 	CommitFileId  string `gorm:"primaryKey;type:varchar(255)"`
 	ComponentName string `gorm:"type:varchar(255)"`
 }
 
+func (commitFileComponent20220913) TableName() string {
+	return "commit_file_components"
+}
+
 func (script *fixCommitFileIdTooLong) Up(basicRes core.BasicRes) errors.Error {
 	// To recalculate the primary key values for the `commit_files` since
 	// we used the `FilePath` as part of the primary key which would exceed
diff --git a/plugins/jira/models/migrationscripts/20220716_add_init_tables.go b/plugins/jira/models/migrationscripts/20220716_add_init_tables.go
index 87445a22..cee22c6f 100644
--- a/plugins/jira/models/migrationscripts/20220716_add_init_tables.go
+++ b/plugins/jira/models/migrationscripts/20220716_add_init_tables.go
@@ -34,6 +34,10 @@ type jiraConnection20220716After struct {
 	archived.BasicAuth      `mapstructure:",squash"`
 }
 
+func (jiraConnection20220716After) TableName() string {
+	return "_tool_jira_connections"
+}
+
 type jiraConnection20220716Before struct {
 	ID                         uint64    `gorm:"primaryKey" json:"id"`
 	CreatedAt                  time.Time `json:"createdAt"`
@@ -48,6 +52,10 @@ type jiraConnection20220716Before struct {
 	RateLimit                  int       `comment:"api request rate limt per hour" json:"rateLimit"`
 }
 
+func (jiraConnection20220716Before) TableName() string {
+	return "_tool_jira_connections"
+}
+
 type addInitTables20220716 struct{}
 
 func (script *addInitTables20220716) Up(basicRes core.BasicRes) errors.Error {