2020-05-14 22:55:43 +00:00
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
2022-11-27 18:20:29 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-05-14 22:55:43 +00:00
|
|
|
|
2022-11-02 08:54:36 +00:00
|
|
|
package v1_12 //nolint
|
2020-05-14 22:55:43 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
|
|
|
|
"xorm.io/xorm"
|
|
|
|
)
|
|
|
|
|
2022-11-02 08:54:36 +00:00
|
|
|
func PrependRefsHeadsToIssueRefs(x *xorm.Engine) error {
|
2020-05-14 22:55:43 +00:00
|
|
|
var query string
|
|
|
|
|
|
|
|
switch {
|
2023-03-07 12:11:44 +00:00
|
|
|
case setting.Database.Type.IsMSSQL():
|
2020-05-14 22:55:43 +00:00
|
|
|
query = "UPDATE `issue` SET `ref` = 'refs/heads/' + `ref` WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%'"
|
2023-03-07 12:11:44 +00:00
|
|
|
case setting.Database.Type.IsMySQL():
|
2020-05-15 14:05:18 +00:00
|
|
|
query = "UPDATE `issue` SET `ref` = CONCAT('refs/heads/', `ref`) WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%';"
|
2020-05-14 22:55:43 +00:00
|
|
|
default:
|
|
|
|
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
|
|
|
|
}
|