You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2022/07/19 07:50:54 UTC

[incubator-devlake] branch main updated (f8a12121 -> dc1b6119)

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

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


    from f8a12121 fix: fix the schema of transformationRules (#2536)
     new 8a017cc8 fix: jira verify enckey and jira encode password
     new 8ec77dc5 fix: jira verify enckey and jira encode password
     new b40095d0 fix: jira verify enckey and jira encode password and typo
     new a5b3e1a0 fix: jira verify enckey and jira encode password
     new 0dbbb17f fix: jira verify enckey and jira encode password
     new dc1b6119 fix: jira verify enckey and jira encode password

The 6 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:
 generator/cmd/init_migration.go                    |  2 +-
 .../archived/connection_history.go                 | 56 ---------------
 .../models/migrationscripts/archived/source.go     | 55 +++++++++++++++
 .../jira/models/migrationscripts/init_schema.go    | 80 ++++++++++------------
 .../models/migrationscripts/pre_init_schemas.go    | 65 ++++++++++++++++++
 plugins/jira/models/migrationscripts/register.go   |  1 +
 6 files changed, 157 insertions(+), 102 deletions(-)
 delete mode 100644 plugins/jira/models/migrationscripts/archived/connection_history.go
 create mode 100644 plugins/jira/models/migrationscripts/archived/source.go
 create mode 100644 plugins/jira/models/migrationscripts/pre_init_schemas.go


[incubator-devlake] 06/06: fix: jira verify enckey and jira encode password

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit dc1b6119376ae0db12664562e414aa495192004c
Author: abeizn <zi...@merico.dev>
AuthorDate: Tue Jul 19 15:31:23 2022 +0800

    fix: jira verify enckey and jira encode password
---
 plugins/jira/models/migrationscripts/init_schema.go      | 10 +++++-----
 plugins/jira/models/migrationscripts/pre_init_schemas.go | 16 ++++++++--------
 plugins/jira/models/migrationscripts/register.go         |  2 +-
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/plugins/jira/models/migrationscripts/init_schema.go b/plugins/jira/models/migrationscripts/init_schema.go
index 7c60c3b6..2545751d 100644
--- a/plugins/jira/models/migrationscripts/init_schema.go
+++ b/plugins/jira/models/migrationscripts/init_schema.go
@@ -30,7 +30,7 @@ import (
 	"gorm.io/gorm"
 )
 
-type JiraConnectionV11 struct {
+type JiraConnectionV011 struct {
 	ID                         uint64    `gorm:"primaryKey" json:"id"`
 	CreatedAt                  time.Time `json:"createdAt"`
 	UpdatedAt                  time.Time `json:"updatedAt"`
@@ -44,7 +44,7 @@ type JiraConnectionV11 struct {
 	RateLimit                  int       `comment:"api request rate limt per hour" json:"rateLimit"`
 }
 
-func (JiraConnectionV11) TableName() string {
+func (JiraConnectionV011) TableName() string {
 	return "_tool_jira_connections"
 }
 
@@ -86,12 +86,12 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
 	var result *gorm.DB
 	m := db.Migrator()
 
-	if m.HasTable(&JiraConnectionV11{}) {
-		var jiraConns []JiraConnectionV11
+	if m.HasTable(&JiraConnectionV011{}) {
+		var jiraConns []JiraConnectionV011
 		result = db.Find(&jiraConns)
 
 		if result.Error == nil {
-			err := db.Migrator().DropTable(&JiraConnectionV11{})
+			err := db.Migrator().DropTable(&JiraConnectionV011{})
 			if err != nil {
 				return err
 			}
diff --git a/plugins/jira/models/migrationscripts/pre_init_schemas.go b/plugins/jira/models/migrationscripts/pre_init_schemas.go
index c75aa459..d5d8b8a9 100644
--- a/plugins/jira/models/migrationscripts/pre_init_schemas.go
+++ b/plugins/jira/models/migrationscripts/pre_init_schemas.go
@@ -23,7 +23,7 @@ import (
 	"gorm.io/gorm"
 )
 
-type JiraConnection20220505 struct {
+type JiraConnectionV010 struct {
 	common.Model
 	Name                       string `gorm:"type:varchar(100);uniqueIndex" json:"name" validate:"required"`
 	Endpoint                   string `json:"endpoint" validate:"required"`
@@ -35,16 +35,16 @@ type JiraConnection20220505 struct {
 	RateLimit                  int    `comment:"api request rate limt per hour" json:"rateLimit"`
 }
 
-func (JiraConnection20220505) TableName() string {
+func (JiraConnectionV010) TableName() string {
 	return "_tool_jira_connections"
 }
 
-type UpdateSchemas20220505 struct{}
+type PreJiraInitSchemas struct{}
 
-func (*UpdateSchemas20220505) Up(ctx context.Context, db *gorm.DB) error {
+func (*PreJiraInitSchemas) Up(ctx context.Context, db *gorm.DB) error {
 	m := db.Migrator()
 	if m.HasTable(&archived.JiraSource{}) && !m.HasTable(&archived.JiraConnection{}) {
-		err := db.Migrator().RenameTable(archived.JiraSource{}, JiraConnection20220505{})
+		err := db.Migrator().RenameTable(archived.JiraSource{}, JiraConnectionV010{})
 		if err != nil {
 			return err
 		}
@@ -52,14 +52,14 @@ func (*UpdateSchemas20220505) Up(ctx context.Context, db *gorm.DB) error {
 	return nil
 }
 
-func (*UpdateSchemas20220505) Version() uint64 {
+func (*PreJiraInitSchemas) Version() uint64 {
 	return 20220505212344
 }
 
-func (*UpdateSchemas20220505) Owner() string {
+func (*PreJiraInitSchemas) Owner() string {
 	return "Jira"
 }
 
-func (*UpdateSchemas20220505) Name() string {
+func (*PreJiraInitSchemas) Name() string {
 	return "preparation for jira init_schemas"
 }
diff --git a/plugins/jira/models/migrationscripts/register.go b/plugins/jira/models/migrationscripts/register.go
index e1634eae..78b36264 100644
--- a/plugins/jira/models/migrationscripts/register.go
+++ b/plugins/jira/models/migrationscripts/register.go
@@ -24,7 +24,7 @@ import (
 // All return all the migration scripts
 func All() []migration.Script {
 	return []migration.Script{
-		new(UpdateSchemas20220505),
+		new(PreJiraInitSchemas),
 		new(InitSchemas),
 	}
 }


[incubator-devlake] 01/06: fix: jira verify enckey and jira encode password

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8a017cc8e5b06970a7469dbd51b31ac240d8a7db
Author: abeizn <zi...@merico.dev>
AuthorDate: Mon Jul 18 22:46:21 2022 +0800

    fix: jira verify enckey and jira encode password
---
 plugins/jira/models/migrationscripts/init_schema.go | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/plugins/jira/models/migrationscripts/init_schema.go b/plugins/jira/models/migrationscripts/init_schema.go
index fe35842f..e823670f 100644
--- a/plugins/jira/models/migrationscripts/init_schema.go
+++ b/plugins/jira/models/migrationscripts/init_schema.go
@@ -20,6 +20,7 @@ package migrationscripts
 import (
 	"context"
 	"encoding/base64"
+	"fmt"
 	"strings"
 
 	"github.com/apache/incubator-devlake/config"
@@ -90,6 +91,9 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
 
 				c := config.GetConfig()
 				encKey := c.GetString("ENCODE_KEY")
+				if encKey == "" {
+					return fmt.Errorf("jira v0.11 invalid encKey")
+				}
 				auth, err := core.Decrypt(encKey, v.BasicAuthEncoded)
 				if err != nil {
 					return err
@@ -101,7 +105,10 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
 				originInfo := strings.Split(string(pk), ":")
 				if len(originInfo) == 2 {
 					conn.Username = originInfo[0]
-					conn.Password = originInfo[1]
+					conn.Password, err = core.Encrypt(encKey, originInfo[1])
+					if err != nil {
+						return err
+					}
 					// create
 					db.Create(&conn)
 				}
@@ -131,6 +138,9 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
 
 				c := config.GetConfig()
 				encKey := c.GetString("ENCODE_KEY")
+				if encKey == "" {
+					return fmt.Errorf("jia v0.10 invalid encKey")
+				}
 				auth, err := core.Decrypt(encKey, v.BasicAuthEncoded)
 				if err != nil {
 					return err
@@ -142,7 +152,10 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
 				originInfo := strings.Split(string(pk), ":")
 				if len(originInfo) == 2 {
 					conn.Username = originInfo[0]
-					conn.Password = originInfo[1]
+					conn.Password, err = core.Encrypt(encKey, originInfo[1])
+					if err != nil {
+						return err
+					}
 					// create
 					db.Create(&conn)
 				}


[incubator-devlake] 05/06: fix: jira verify enckey and jira encode password

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 0dbbb17f442a332f27293a1ac8512c3102957e19
Author: abeizn <zi...@merico.dev>
AuthorDate: Tue Jul 19 15:08:10 2022 +0800

    fix: jira verify enckey and jira encode password
---
 .../migrationscripts/{updataSchemas20220505.go => pre_init_schemas.go}  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/jira/models/migrationscripts/updataSchemas20220505.go b/plugins/jira/models/migrationscripts/pre_init_schemas.go
similarity index 98%
rename from plugins/jira/models/migrationscripts/updataSchemas20220505.go
rename to plugins/jira/models/migrationscripts/pre_init_schemas.go
index 19f43991..c75aa459 100644
--- a/plugins/jira/models/migrationscripts/updataSchemas20220505.go
+++ b/plugins/jira/models/migrationscripts/pre_init_schemas.go
@@ -61,5 +61,5 @@ func (*UpdateSchemas20220505) Owner() string {
 }
 
 func (*UpdateSchemas20220505) Name() string {
-	return "Rename source to connection "
+	return "preparation for jira init_schemas"
 }


[incubator-devlake] 04/06: fix: jira verify enckey and jira encode password

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a5b3e1a09e233b4cc9c324fb993e96e5b2765fc8
Author: abeizn <zi...@merico.dev>
AuthorDate: Tue Jul 19 14:41:39 2022 +0800

    fix: jira verify enckey and jira encode password
---
 generator/cmd/init_migration.go                    |  2 +-
 .../archived/connection_history.go                 | 56 ----------------
 .../models/migrationscripts/archived/source.go     | 55 ++++++++++++++++
 .../jira/models/migrationscripts/init_schema.go    | 74 +++++++---------------
 plugins/jira/models/migrationscripts/register.go   |  1 +
 .../migrationscripts/updataSchemas20220505.go      | 65 +++++++++++++++++++
 6 files changed, 145 insertions(+), 108 deletions(-)

diff --git a/generator/cmd/init_migration.go b/generator/cmd/init_migration.go
index 58e2a462..ebc4f17a 100644
--- a/generator/cmd/init_migration.go
+++ b/generator/cmd/init_migration.go
@@ -63,7 +63,7 @@ Type in which plugin do you want init migrations in, then generator will create
 
 		// read template
 		templates := map[string]string{
-			`initSchema.go`:     util.ReadTemplate("generator/template/migrationscripts/init_domain_schemas.go-template"),
+			`initSchema.go`:     util.ReadTemplate("generator/template/migrationscripts/init_schemas.go-template"),
 			`register.go`:       util.ReadTemplate("generator/template/migrationscripts/register.go-template"),
 			`archived/.gitkeep`: ``,
 		}
diff --git a/plugins/jira/models/migrationscripts/archived/connection_history.go b/plugins/jira/models/migrationscripts/archived/connection_history.go
deleted file mode 100644
index fae6f10f..00000000
--- a/plugins/jira/models/migrationscripts/archived/connection_history.go
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package archived
-
-import "time"
-
-type JiraConnectionV11 struct {
-	ID                         uint64    `gorm:"primaryKey" json:"id"`
-	CreatedAt                  time.Time `json:"createdAt"`
-	UpdatedAt                  time.Time `json:"updatedAt"`
-	Name                       string    `gorm:"type:varchar(100);uniqueIndex" json:"name" validate:"required"`
-	Endpoint                   string    `json:"endpoint" validate:"required"`
-	BasicAuthEncoded           string    `json:"basicAuthEncoded" validate:"required"`
-	EpicKeyField               string    `gorm:"type:varchar(50);" json:"epicKeyField"`
-	StoryPointField            string    `gorm:"type:varchar(50);" json:"storyPointField"`
-	RemotelinkCommitShaPattern string    `gorm:"type:varchar(255);comment='golang regexp, the first group will be recognized as commit sha, ref https://github.com/google/re2/wiki/Syntax'" json:"remotelinkCommitShaPattern"`
-	Proxy                      string    `json:"proxy"`
-	RateLimitPerHour           int       `comment:"api request rate limt per hour" json:"rateLimit"`
-}
-
-func (JiraConnectionV11) TableName() string {
-	return "_tool_jira_connections"
-}
-
-type JiraConnectionV10 struct {
-	ID                         uint64    `gorm:"primaryKey" json:"id"`
-	CreatedAt                  time.Time `json:"createdAt"`
-	UpdatedAt                  time.Time `json:"updatedAt"`
-	Name                       string    `gorm:"type:varchar(100);uniqueIndex" json:"name" validate:"required"`
-	Endpoint                   string    `json:"endpoint" validate:"required"`
-	BasicAuthEncoded           string    `json:"basicAuthEncoded" validate:"required"`
-	EpicKeyField               string    `gorm:"type:varchar(50);" json:"epicKeyField"`
-	StoryPointField            string    `gorm:"type:varchar(50);" json:"storyPointField"`
-	RemotelinkCommitShaPattern string    `gorm:"type:varchar(255);comment='golang regexp, the first group will be recognized as commit sha, ref https://github.com/google/re2/wiki/Syntax'" json:"remotelinkCommitShaPattern"`
-	Proxy                      string    `json:"proxy"`
-	RateLimitPerHour           int       `comment:"api request rate limt per hour" json:"rateLimit"`
-}
-
-func (JiraConnectionV10) TableName() string {
-	return "_tool_jira_source"
-}
diff --git a/plugins/jira/models/migrationscripts/archived/source.go b/plugins/jira/models/migrationscripts/archived/source.go
new file mode 100644
index 00000000..39244699
--- /dev/null
+++ b/plugins/jira/models/migrationscripts/archived/source.go
@@ -0,0 +1,55 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+    http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package archived
+
+import "github.com/apache/incubator-devlake/models/migrationscripts/archived"
+
+type JiraSource struct {
+	archived.Model
+	Name                       string `gorm:"type:varchar(100);uniqueIndex" json:"name" validate:"required"`
+	Endpoint                   string `json:"endpoint" validate:"required"`
+	BasicAuthEncoded           string `json:"basicAuthEncoded" validate:"required"`
+	EpicKeyField               string `gorm:"type:varchar(50);" json:"epicKeyField"`
+	StoryPointField            string `gorm:"type:varchar(50);" json:"storyPointField"`
+	RemotelinkCommitShaPattern string `gorm:"type:varchar(255);comment='golang regexp, the first group will be recognized as commit sha, ref https://github.com/google/re2/wiki/Syntax'" json:"remotelinkCommitShaPattern"`
+	Proxy                      string `json:"proxy"`
+	RateLimit                  int    `comment:"api request rate limt per second"`
+}
+
+type JiraIssueTypeMapping struct {
+	SourceID     uint64 `gorm:"primaryKey" json:"jiraSourceId" validate:"required"`
+	UserType     string `gorm:"type:varchar(50);primaryKey" json:"userType" validate:"required"`
+	StandardType string `gorm:"type:varchar(50)" json:"standardType" validate:"required"`
+}
+
+type JiraIssueStatusMapping struct {
+	SourceID       uint64 `gorm:"primaryKey" json:"jiraSourceId" validate:"required"`
+	UserType       string `gorm:"type:varchar(50);primaryKey" json:"userType" validate:"required"`
+	UserStatus     string `gorm:"type:varchar(50);primaryKey" json:"userStatus" validate:"required"`
+	StandardStatus string `gorm:"type:varchar(50)" json:"standardStatus" validate:"required"`
+}
+
+func (JiraSource) TableName() string {
+	return "_tool_jira_sources"
+}
+
+func (JiraIssueTypeMapping) TableName() string {
+	return "_tool_jira_issue_type_mappings"
+}
+
+func (JiraIssueStatusMapping) TableName() string {
+	return "_tool_jira_issue_status_mappings"
+}
diff --git a/plugins/jira/models/migrationscripts/init_schema.go b/plugins/jira/models/migrationscripts/init_schema.go
index b4d54e52..7c60c3b6 100644
--- a/plugins/jira/models/migrationscripts/init_schema.go
+++ b/plugins/jira/models/migrationscripts/init_schema.go
@@ -22,6 +22,7 @@ import (
 	"encoding/base64"
 	"fmt"
 	"strings"
+	"time"
 
 	"github.com/apache/incubator-devlake/config"
 	"github.com/apache/incubator-devlake/plugins/core"
@@ -29,6 +30,24 @@ import (
 	"gorm.io/gorm"
 )
 
+type JiraConnectionV11 struct {
+	ID                         uint64    `gorm:"primaryKey" json:"id"`
+	CreatedAt                  time.Time `json:"createdAt"`
+	UpdatedAt                  time.Time `json:"updatedAt"`
+	Name                       string    `gorm:"type:varchar(100);uniqueIndex" json:"name" validate:"required"`
+	Endpoint                   string    `json:"endpoint" validate:"required"`
+	BasicAuthEncoded           string    `json:"basicAuthEncoded" validate:"required"`
+	EpicKeyField               string    `gorm:"type:varchar(50);" json:"epicKeyField"`
+	StoryPointField            string    `gorm:"type:varchar(50);" json:"storyPointField"`
+	RemotelinkCommitShaPattern string    `gorm:"type:varchar(255);comment='golang regexp, the first group will be recognized as commit sha, ref https://github.com/google/re2/wiki/Syntax'" json:"remotelinkCommitShaPattern"`
+	Proxy                      string    `json:"proxy"`
+	RateLimit                  int       `comment:"api request rate limt per hour" json:"rateLimit"`
+}
+
+func (JiraConnectionV11) TableName() string {
+	return "_tool_jira_connections"
+}
+
 type InitSchemas struct{}
 
 func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
@@ -67,12 +86,12 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
 	var result *gorm.DB
 	m := db.Migrator()
 
-	if m.HasTable(&archived.JiraConnectionV11{}) {
-		var jiraConns []archived.JiraConnectionV11
+	if m.HasTable(&JiraConnectionV11{}) {
+		var jiraConns []JiraConnectionV11
 		result = db.Find(&jiraConns)
 
 		if result.Error == nil {
-			err := db.Migrator().DropTable(&archived.JiraConnectionV11{})
+			err := db.Migrator().DropTable(&JiraConnectionV11{})
 			if err != nil {
 				return err
 			}
@@ -87,7 +106,7 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
 				conn.Name = v.Name
 				conn.Endpoint = v.Endpoint
 				conn.Proxy = v.Proxy
-				conn.RateLimitPerHour = v.RateLimitPerHour
+				conn.RateLimitPerHour = v.RateLimit
 
 				c := config.GetConfig()
 				encKey := c.GetString("ENCODE_KEY")
@@ -114,53 +133,6 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
 				}
 			}
 		}
-	} else if m.HasTable(&archived.JiraConnectionV10{}) {
-		var jiraConns []archived.JiraConnectionV10
-		result = db.Find(&jiraConns)
-
-		if result.Error == nil {
-			err := db.Migrator().DropTable(&archived.JiraConnectionV10{})
-			if err != nil {
-				return err
-			}
-			err = db.Migrator().AutoMigrate(&archived.JiraConnection{})
-			if err != nil {
-				return err
-			}
-
-			for _, v := range jiraConns {
-				conn := &archived.JiraConnection{}
-				conn.ID = v.ID
-				conn.Name = v.Name
-				conn.Endpoint = v.Endpoint
-				conn.Proxy = v.Proxy
-				conn.RateLimitPerHour = v.RateLimitPerHour
-
-				c := config.GetConfig()
-				encKey := c.GetString("ENCODE_KEY")
-				if encKey == "" {
-					return fmt.Errorf("jira v0.10 invalid encKey")
-				}
-				auth, err := core.Decrypt(encKey, v.BasicAuthEncoded)
-				if err != nil {
-					return err
-				}
-				pk, err := base64.StdEncoding.DecodeString(auth)
-				if err != nil {
-					return err
-				}
-				originInfo := strings.Split(string(pk), ":")
-				if len(originInfo) == 2 {
-					conn.Username = originInfo[0]
-					conn.Password, err = core.Encrypt(encKey, originInfo[1])
-					if err != nil {
-						return err
-					}
-					// create
-					db.Create(&conn)
-				}
-			}
-		}
 	} else {
 		c := config.GetConfig()
 		encKey := c.GetString("ENCODE_KEY")
diff --git a/plugins/jira/models/migrationscripts/register.go b/plugins/jira/models/migrationscripts/register.go
index 06d924d0..e1634eae 100644
--- a/plugins/jira/models/migrationscripts/register.go
+++ b/plugins/jira/models/migrationscripts/register.go
@@ -24,6 +24,7 @@ import (
 // All return all the migration scripts
 func All() []migration.Script {
 	return []migration.Script{
+		new(UpdateSchemas20220505),
 		new(InitSchemas),
 	}
 }
diff --git a/plugins/jira/models/migrationscripts/updataSchemas20220505.go b/plugins/jira/models/migrationscripts/updataSchemas20220505.go
new file mode 100644
index 00000000..19f43991
--- /dev/null
+++ b/plugins/jira/models/migrationscripts/updataSchemas20220505.go
@@ -0,0 +1,65 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+    http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"context"
+
+	"github.com/apache/incubator-devlake/models/common"
+	"github.com/apache/incubator-devlake/plugins/jira/models/migrationscripts/archived"
+	"gorm.io/gorm"
+)
+
+type JiraConnection20220505 struct {
+	common.Model
+	Name                       string `gorm:"type:varchar(100);uniqueIndex" json:"name" validate:"required"`
+	Endpoint                   string `json:"endpoint" validate:"required"`
+	BasicAuthEncoded           string `json:"basicAuthEncoded" validate:"required"`
+	EpicKeyField               string `gorm:"type:varchar(50);" json:"epicKeyField"`
+	StoryPointField            string `gorm:"type:varchar(50);" json:"storyPointField"`
+	RemotelinkCommitShaPattern string `gorm:"type:varchar(255);comment='golang regexp, the first group will be recognized as commit sha, ref https://github.com/google/re2/wiki/Syntax'" json:"remotelinkCommitShaPattern"`
+	Proxy                      string `json:"proxy"`
+	RateLimit                  int    `comment:"api request rate limt per hour" json:"rateLimit"`
+}
+
+func (JiraConnection20220505) TableName() string {
+	return "_tool_jira_connections"
+}
+
+type UpdateSchemas20220505 struct{}
+
+func (*UpdateSchemas20220505) Up(ctx context.Context, db *gorm.DB) error {
+	m := db.Migrator()
+	if m.HasTable(&archived.JiraSource{}) && !m.HasTable(&archived.JiraConnection{}) {
+		err := db.Migrator().RenameTable(archived.JiraSource{}, JiraConnection20220505{})
+		if err != nil {
+			return err
+		}
+	}
+	return nil
+}
+
+func (*UpdateSchemas20220505) Version() uint64 {
+	return 20220505212344
+}
+
+func (*UpdateSchemas20220505) Owner() string {
+	return "Jira"
+}
+
+func (*UpdateSchemas20220505) Name() string {
+	return "Rename source to connection "
+}


[incubator-devlake] 03/06: fix: jira verify enckey and jira encode password and typo

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b40095d06ecc21977cceeb4fc6e9298300679482
Author: abeizn <zi...@merico.dev>
AuthorDate: Mon Jul 18 23:50:24 2022 +0800

    fix: jira verify enckey and jira encode password and typo
---
 plugins/jira/models/migrationscripts/init_schema.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/jira/models/migrationscripts/init_schema.go b/plugins/jira/models/migrationscripts/init_schema.go
index 44e6b458..b4d54e52 100644
--- a/plugins/jira/models/migrationscripts/init_schema.go
+++ b/plugins/jira/models/migrationscripts/init_schema.go
@@ -139,7 +139,7 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
 				c := config.GetConfig()
 				encKey := c.GetString("ENCODE_KEY")
 				if encKey == "" {
-					return fmt.Errorf("jia v0.10 invalid encKey")
+					return fmt.Errorf("jira v0.10 invalid encKey")
 				}
 				auth, err := core.Decrypt(encKey, v.BasicAuthEncoded)
 				if err != nil {


[incubator-devlake] 02/06: fix: jira verify enckey and jira encode password

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8ec77dc5edd9cccf83f91a28c7445a677b7db0af
Author: abeizn <zi...@merico.dev>
AuthorDate: Mon Jul 18 23:25:42 2022 +0800

    fix: jira verify enckey and jira encode password
---
 plugins/jira/models/migrationscripts/init_schema.go | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/plugins/jira/models/migrationscripts/init_schema.go b/plugins/jira/models/migrationscripts/init_schema.go
index e823670f..44e6b458 100644
--- a/plugins/jira/models/migrationscripts/init_schema.go
+++ b/plugins/jira/models/migrationscripts/init_schema.go
@@ -162,6 +162,11 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
 			}
 		}
 	} else {
+		c := config.GetConfig()
+		encKey := c.GetString("ENCODE_KEY")
+		if encKey == "" {
+			return fmt.Errorf("invalid encKey")
+		}
 		err := db.Migrator().AutoMigrate(&archived.JiraConnection{})
 		if err != nil {
 			return err