summaryrefslogtreecommitdiffstats
path: root/models/migrations/v67.go
diff options
context:
space:
mode:
authorFlorian Eitel <feitel@indeedgeek.de>2018-11-18 21:34:14 +0100
committerLauris BH <lauris@nix.lv>2018-11-18 22:34:14 +0200
commitffc0c7f611a957e3848d810578579bc3566e311c (patch)
tree2b82e22fb0c4e0a3dbef155d9d4f9b21c6d9dfc7 /models/migrations/v67.go
parent8670decafbf00291c3a2d203925b5d73a49e78a6 (diff)
downloadgitea-ffc0c7f611a957e3848d810578579bc3566e311c.tar.gz
gitea-ffc0c7f611a957e3848d810578579bc3566e311c.zip
Migration fixes 5318 1.6 backport (#5355)
* Remove field from migration to support upgrades from older version That will ensure the field does not get queried in the Select if it does not exist yet: ``` [I] [SQL] SELECT "id", "repo_id", "index", "poster_id", "name", "content", "milestone_id", "priority", "assignee_id", "is_closed", "is_pull", "num_comments", "ref", "deadline_unix", "created_unix", "updated_unix [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: pq: column "ref" does not exist ``` see #5318 * Skip remove stale watcher migration if not required Otherwise the migration will fail if executed from a older database version without multiple IssueWatch feature. ``` 2018/11/11 23:51:14 [I] [SQL] SELECT DISTINCT "issue_watch"."user_id", "issue"."repo_id" FROM "issue_watch" INNER JOIN issue ON issue_watch.issue_id = issue.id WHERE (issue_watch.is_watching = $1) LIMIT 50 []int [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: pq: relation "issue_watch" does not exist ``` see #5318
Diffstat (limited to 'models/migrations/v67.go')
-rw-r--r--models/migrations/v67.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/models/migrations/v67.go b/models/migrations/v67.go
index 2782219191..d4a7497ec9 100644
--- a/models/migrations/v67.go
+++ b/models/migrations/v67.go
@@ -5,6 +5,8 @@
package migrations
import (
+ "fmt"
+
"code.gitea.io/gitea/modules/setting"
"github.com/go-xorm/xorm"
@@ -70,6 +72,13 @@ func removeStaleWatches(x *xorm.Engine) error {
return err
}
+ var issueWatch IssueWatch
+ if exist, err := sess.IsTableExist(&issueWatch); err != nil {
+ return fmt.Errorf("IsExist IssueWatch: %v", err)
+ } else if !exist {
+ return nil
+ }
+
repoCache := make(map[int64]*Repository)
err := x.BufferSize(setting.IterateBufferSize).Iterate(new(Watch),
func(idx int, bean interface{}) error {