2020-05-14 18:55:43 -04:00
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package migrations
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
|
|
|
|
"xorm.io/xorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
func prependRefsHeadsToIssueRefs(x *xorm.Engine) error {
|
|
|
|
var query string
|
|
|
|
|
|
|
|
switch {
|
|
|
|
case setting.Database.UseMSSQL:
|
|
|
|
query = "UPDATE `issue` SET `ref` = 'refs/heads/' + `ref` WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%'"
|
2020-05-15 10:05:18 -04:00
|
|
|
case setting.Database.UseMySQL:
|
|
|
|
query = "UPDATE `issue` SET `ref` = CONCAT('refs/heads/', `ref`) WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%';"
|
2020-05-14 18:55:43 -04: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
|
|
|
|
}
|