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 2023/08/21 08:09:25 UTC
[incubator-devlake] branch fix#5867 updated: fix: modify cicd_pipelines name from varchar to text
This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch fix#5867
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/fix#5867 by this push:
new 208386995 fix: modify cicd_pipelines name from varchar to text
208386995 is described below
commit 208386995fd0fa162ed2813a2111105ce5510e8f
Author: abeizn <zi...@merico.dev>
AuthorDate: Mon Aug 21 16:09:15 2023 +0800
fix: modify cicd_pipelines name from varchar to text
---
.../20230821_modify_cicd_pipelines_to_text.go | 66 ++++++++++++++++++++++
backend/core/models/migrationscripts/register.go | 1 +
2 files changed, 67 insertions(+)
diff --git a/backend/core/models/migrationscripts/20230821_modify_cicd_pipelines_to_text.go b/backend/core/models/migrationscripts/20230821_modify_cicd_pipelines_to_text.go
new file mode 100644
index 000000000..d45a9d994
--- /dev/null
+++ b/backend/core/models/migrationscripts/20230821_modify_cicd_pipelines_to_text.go
@@ -0,0 +1,66 @@
+/*
+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 = (*modifyCicdPipelinesToText)(nil)
+
+type modifyCicdPipelinesToText struct{}
+
+type cicdPipeline20230821 struct {
+ Name string
+}
+
+func (cicdPipeline20230821) TableName() string {
+ return "cicd_pipelines"
+}
+
+func (script *modifyCicdPipelinesToText) Up(basicRes context.BasicRes) errors.Error {
+ // cicd_pipelines.name might be text, we ought to change the type
+ // for the column from `varchar(255)` to `text`
+ db := basicRes.GetDal()
+ return migrationhelper.ChangeColumnsType[cicdPipeline20230821](
+ basicRes,
+ script,
+ cicdPipeline20230821{}.TableName(),
+ []string{"name"},
+ func(tmpColumnParams []interface{}) errors.Error {
+ return db.UpdateColumn(
+ &cicdPipeline20230821{},
+ "name",
+ dal.DalClause{Expr: " ? ", Params: tmpColumnParams},
+ dal.Where("? != '' ", tmpColumnParams...),
+ )
+ },
+ )
+}
+
+func (*modifyCicdPipelinesToText) Version() uint64 {
+ return 20230821145125
+}
+
+func (*modifyCicdPipelinesToText) Name() string {
+ return "modify cicd_pipelines name from varchar to text"
+}
diff --git a/backend/core/models/migrationscripts/register.go b/backend/core/models/migrationscripts/register.go
index fce6fd239..a7e325ca8 100644
--- a/backend/core/models/migrationscripts/register.go
+++ b/backend/core/models/migrationscripts/register.go
@@ -89,5 +89,6 @@ func All() []plugin.MigrationScript {
new(addApiKeyTables),
new(addIssueRelationship),
new(tasksUsesJSON),
+ new(modifyCicdPipelinesToText),
}
}