2020-05-15 00:55:43 +02:00
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
2022-11-27 19:20:29 +01:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-05-15 00:55:43 +02:00
|
|
|
|
2022-11-02 09:54:36 +01:00
|
|
|
package v1_12 //nolint
|
2020-05-15 00:55:43 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
|
|
|
|
"xorm.io/xorm"
|
|
|
|
)
|
|
|
|
|
2022-11-02 09:54:36 +01:00
|
|
|
func PrependRefsHeadsToIssueRefs(x *xorm.Engine) error {
|
2020-05-15 00:55:43 +02:00
|
|
|
var query string
|
|
|
|
|
2024-04-04 18:02:24 +02:00
|
|
|
if setting.Database.Type.IsMySQL() {
|
2020-05-15 16:05:18 +02:00
|
|
|
query = "UPDATE `issue` SET `ref` = CONCAT('refs/heads/', `ref`) WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%';"
|
2024-04-04 18:02:24 +02:00
|
|
|
} else {
|
2020-05-15 00:55:43 +02:00
|
|
|
query = "UPDATE `issue` SET `ref` = 'refs/heads/' || `ref` WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%'"
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err := x.Exec(query)
|
|
|
|
return err
|
|
|
|
}
|