You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by pe...@apache.org on 2025/10/22 17:04:31 UTC
(incubator-devlake) 01/01: fix(pipeline): fix priority
This is an automated email from the ASF dual-hosted git repository.
petkostas pushed a commit to branch fix/issue-8621-fix-null-priority
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit ddd154fedc286982467d9c902a739bbc0350a3d0
Author: Kostas Petrakis <pe...@mail.com>
AuthorDate: Wed Oct 22 20:04:09 2025 +0300
fix(pipeline): fix priority
- The newly introduced priority field is set to NULL by default, which
causes pre-existing pipelines to crash devlake when starting after a
version upgrade.
---
.../migrationscripts/20251022_fix_null_priority.go | 67 ++++++++++++++++++++++
backend/core/models/migrationscripts/register.go | 1 +
2 files changed, 68 insertions(+)
diff --git a/backend/core/models/migrationscripts/20251022_fix_null_priority.go b/backend/core/models/migrationscripts/20251022_fix_null_priority.go
new file mode 100644
index 000000000..8b3dda0db
--- /dev/null
+++ b/backend/core/models/migrationscripts/20251022_fix_null_priority.go
@@ -0,0 +1,67 @@
+/*
+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"
+)
+
+var _ plugin.MigrationScript = (*fixNullPriority)(nil)
+
+type fixNullPriority struct{}
+
+type blueprint20251022 struct {
+ Priority int `json:"priority"`
+}
+
+func (blueprint20251022) TableName() string {
+ return "_devlake_blueprints"
+}
+
+type pipeline20251022 struct {
+ Priority int `json:"priority"`
+}
+
+func (pipeline20251022) TableName() string {
+ return "_devlake_pipelines"
+}
+
+func (*fixNullPriority) Up(basicRes context.BasicRes) errors.Error {
+ // Set default value 0 for NULL priority values in existing rows
+ db := basicRes.GetDal()
+ err := db.UpdateColumn(&blueprint20251022{}, "priority", 0, dal.Where("priority IS NULL"))
+ if err != nil {
+ return err
+ }
+ err = db.UpdateColumn(&pipeline20251022{}, "priority", 0, dal.Where("priority IS NULL"))
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+func (*fixNullPriority) Version() uint64 {
+ return 20251022195645
+}
+
+func (*fixNullPriority) Name() string {
+ return "fix null priority values in blueprints and pipelines"
+}
diff --git a/backend/core/models/migrationscripts/register.go b/backend/core/models/migrationscripts/register.go
index c14ae8740..363de1b5e 100644
--- a/backend/core/models/migrationscripts/register.go
+++ b/backend/core/models/migrationscripts/register.go
@@ -140,5 +140,6 @@ func All() []plugin.MigrationScript {
new(extendFieldSizeForCq),
new(addIssueFixVerion),
new(addPipelinePriority),
+ new(fixNullPriority),
}
}