mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 11:28:24 +00:00 
			
		
		
		
	There are too many files in `models/migrations` folder so that I split them into sub folders.
		
			
				
	
	
		
			28 lines
		
	
	
		
			856 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			856 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // 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 v1_12 //nolint
 | |
| 
 | |
| 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/%'"
 | |
| 	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/%';"
 | |
| 	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
 | |
| }
 |