You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

v139.go 852B

123456789101112131415161718192021222324252627
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package migrations
  5. import (
  6. "code.gitea.io/gitea/modules/setting"
  7. "xorm.io/xorm"
  8. )
  9. func prependRefsHeadsToIssueRefs(x *xorm.Engine) error {
  10. var query string
  11. switch {
  12. case setting.Database.UseMSSQL:
  13. query = "UPDATE `issue` SET `ref` = 'refs/heads/' + `ref` WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%'"
  14. case setting.Database.UseMySQL:
  15. query = "UPDATE `issue` SET `ref` = CONCAT('refs/heads/', `ref`) WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%';"
  16. default:
  17. query = "UPDATE `issue` SET `ref` = 'refs/heads/' || `ref` WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%'"
  18. }
  19. _, err := x.Exec(query)
  20. return err
  21. }