diff --git a/models/migrations/v139.go b/models/migrations/v139.go
index ffacad0a094..46b14b9869b 100644
--- a/models/migrations/v139.go
+++ b/models/migrations/v139.go
@@ -16,6 +16,8 @@ func prependRefsHeadsToIssueRefs(x *xorm.Engine) error {
 	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/%'"
 	}