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

klesh 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 5425d9e3c fix(pipeline): fix priority (#8622)
5425d9e3c is described below

commit 5425d9e3c1eb4adb6da31b2cc126271cee221db8
Author: Kostas Petrakis <[email protected]>
AuthorDate: Fri Oct 24 08:35:11 2025 +0200

    fix(pipeline): fix priority (#8622)
    
    - 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.
    
    Co-authored-by: Kostas Petrakis <[email protected]>
---
 .../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),
        }
 }

Reply via email to