You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by zh...@apache.org on 2023/07/03 07:09:28 UTC
[incubator-devlake] branch release-v0.17 updated: cherry-pick(v0.17.0-beta): #5208#5255 (#5616)
This is an automated email from the ASF dual-hosted git repository.
zhangliang2022 pushed a commit to branch release-v0.17
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/release-v0.17 by this push:
new c9fb31b8d cherry-pick(v0.17.0-beta): #5208#5255 (#5616)
c9fb31b8d is described below
commit c9fb31b8d35f31d7b9759dc14479b44cfc4326af
Author: Liang Zhang <li...@merico.dev>
AuthorDate: Mon Jul 3 15:09:24 2023 +0800
cherry-pick(v0.17.0-beta): #5208#5255 (#5616)
* Use text instead of varchar(255) for GitHubRun's name (#5208)
* Remove workflow name length validation
Change gorm type from `varchar(255)` to `text` for `GithubRun` type `Name` field.
* Add GithubRun migration script from varchar255 to text
* fix: fix the migration script of _tool_github_runs (#5255)
---------
Co-authored-by: Aidas Vyšniauskas <ai...@teliacompany.com>
---
.../20230518_fix_run_name_to_text.go | 70 ++++++++++++++++++++++
.../github/models/migrationscripts/register.go | 1 +
backend/plugins/github/models/run.go | 2 +-
3 files changed, 72 insertions(+), 1 deletion(-)
diff --git a/backend/plugins/github/models/migrationscripts/20230518_fix_run_name_to_text.go b/backend/plugins/github/models/migrationscripts/20230518_fix_run_name_to_text.go
new file mode 100644
index 000000000..c1eaee16e
--- /dev/null
+++ b/backend/plugins/github/models/migrationscripts/20230518_fix_run_name_to_text.go
@@ -0,0 +1,70 @@
+/*
+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/errors"
+ "github.com/apache/incubator-devlake/helpers/migrationhelper"
+)
+
+type fixRunNameToText struct{}
+
+type githubRun20230518_old struct {
+ ConnectionId uint64 `gorm:"primaryKey"`
+ RepoId int `gorm:"primaryKey"`
+ ID int `gorm:"primaryKey;autoIncrement:false"`
+ Name string `gorm:"type:varchar(255)"`
+}
+type githubRun20230518 struct {
+ ConnectionId uint64 `gorm:"primaryKey"`
+ RepoId int `gorm:"primaryKey"`
+ ID int `gorm:"primaryKey;autoIncrement:false"`
+ Name string `gorm:"type:text"`
+}
+
+func (*fixRunNameToText) Up(baseRes context.BasicRes) errors.Error {
+ err := migrationhelper.TransformColumns(
+ baseRes,
+ &fixRunNameToText{},
+ "_tool_github_runs",
+ []string{"name"},
+ func(src *githubRun20230518_old) (*githubRun20230518, errors.Error) {
+ return &githubRun20230518{
+ ConnectionId: src.ConnectionId,
+ RepoId: src.RepoId,
+ ID: src.ID,
+ Name: src.Name,
+ }, nil
+ },
+ )
+
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (*fixRunNameToText) Version() uint64 {
+ return 20230518000002
+}
+
+func (*fixRunNameToText) Name() string {
+ return "UpdateSchemas for fixRunNameToText"
+}
diff --git a/backend/plugins/github/models/migrationscripts/register.go b/backend/plugins/github/models/migrationscripts/register.go
index 0ea45195b..5139a53f8 100644
--- a/backend/plugins/github/models/migrationscripts/register.go
+++ b/backend/plugins/github/models/migrationscripts/register.go
@@ -37,5 +37,6 @@ func All() []plugin.MigrationScript {
new(addConnectionIdToTransformationRule),
new(addEnvToRunAndJob),
new(addGithubCommitAuthorInfo),
+ new(fixRunNameToText),
}
}
diff --git a/backend/plugins/github/models/run.go b/backend/plugins/github/models/run.go
index 38abaf9cd..7bf55e59e 100644
--- a/backend/plugins/github/models/run.go
+++ b/backend/plugins/github/models/run.go
@@ -27,7 +27,7 @@ type GithubRun struct {
ConnectionId uint64 `gorm:"primaryKey"`
RepoId int `gorm:"primaryKey"`
ID int `json:"id" gorm:"primaryKey;autoIncrement:false"`
- Name string `json:"name" gorm:"type:varchar(255)"`
+ Name string `json:"name" gorm:"type:text"`
NodeID string `json:"node_id" gorm:"type:varchar(255)"`
HeadBranch string `json:"head_branch" gorm:"type:varchar(255)"`
HeadSha string `json:"head_sha" gorm:"type:varchar(255)"`