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
The following commit(s) were added to refs/heads/main by this push:
new 0469859f4 fix: the overflow error of _tool_jira_remotelinks.self
(#5147)
0469859f4 is described below
commit 0469859f45f1adaa1056fcf8eb63112af5cb08c2
Author: Liang Zhang <[email protected]>
AuthorDate: Wed May 10 16:27:02 2023 +0800
fix: the overflow error of _tool_jira_remotelinks.self (#5147)
* fix: the overflow error of _tool_jira_remotelinks.self
* fix: fix the defination of model JiraRemotelink
---
.../20230510_expand_remotelink_selfurl.go | 69 ++++++++++++++++++++++
.../jira/models/migrationscripts/register.go | 1 +
backend/plugins/jira/models/remotelink.go | 2 +-
3 files changed, 71 insertions(+), 1 deletion(-)
diff --git
a/backend/plugins/jira/models/migrationscripts/20230510_expand_remotelink_selfurl.go
b/backend/plugins/jira/models/migrationscripts/20230510_expand_remotelink_selfurl.go
new file mode 100644
index 000000000..b7aeb527b
--- /dev/null
+++
b/backend/plugins/jira/models/migrationscripts/20230510_expand_remotelink_selfurl.go
@@ -0,0 +1,69 @@
+/*
+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 (
+ "github.com/apache/incubator-devlake/core/context"
+ "github.com/apache/incubator-devlake/core/dal"
+ "github.com/apache/incubator-devlake/core/errors"
+ "github.com/apache/incubator-devlake/core/plugin"
+ "github.com/apache/incubator-devlake/helpers/migrationhelper"
+)
+
+var _ plugin.MigrationScript = (*expandRemotelinkUrl)(nil)
+
+type jiraRemotelink20230510 struct {
+ Self string
+}
+
+func (jiraRemotelink20230510) TableName() string {
+ return "_tool_jira_remotelinks"
+}
+
+type expandRemotelinkSelfUrl struct{}
+
+func (script *expandRemotelinkSelfUrl) Up(basicRes context.BasicRes)
errors.Error {
+ db := basicRes.GetDal()
+ // expand _tool_jira_remotelinks.url to LONGTEXT
+ err := migrationhelper.ChangeColumnsType[jiraRemotelink20230510](
+ basicRes,
+ script,
+ jiraRemotelink20230510{}.TableName(),
+ []string{"self"},
+ func(tmpColumnParams []interface{}) errors.Error {
+ return db.UpdateColumn(
+ &jiraRemotelink20230510{},
+ "self",
+ dal.DalClause{Expr: " ? ", Params:
tmpColumnParams},
+ dal.Where("? is not null ", tmpColumnParams...),
+ )
+ },
+ )
+ if err != nil {
+ return err
+ }
+ return err
+}
+
+func (*expandRemotelinkSelfUrl) Version() uint64 {
+ return 20230510110029
+}
+
+func (*expandRemotelinkSelfUrl) Name() string {
+ return "expand _tool_jira_remotelinks.self to LONGTEXT"
+}
diff --git a/backend/plugins/jira/models/migrationscripts/register.go
b/backend/plugins/jira/models/migrationscripts/register.go
index 8e1ba5bf2..a14efc9ec 100644
--- a/backend/plugins/jira/models/migrationscripts/register.go
+++ b/backend/plugins/jira/models/migrationscripts/register.go
@@ -35,5 +35,6 @@ func All() []plugin.MigrationScript {
new(expandRemotelinkUrl),
new(addConnectionIdToTransformationRule),
new(addChangeTotal20230412),
+ new(expandRemotelinkSelfUrl),
}
}
diff --git a/backend/plugins/jira/models/remotelink.go
b/backend/plugins/jira/models/remotelink.go
index 534b4483b..a9de08b13 100644
--- a/backend/plugins/jira/models/remotelink.go
+++ b/backend/plugins/jira/models/remotelink.go
@@ -31,7 +31,7 @@ type JiraRemotelink struct {
RemotelinkId uint64 `gorm:"primarykey"`
IssueId uint64 `gorm:"index"`
RawJson datatypes.JSON
- Self string `gorm:"type:varchar(255)"`
+ Self string
Title string
Url string
IssueUpdated *time.Time