summaryrefslogtreecommitdiffstats
path: root/models/migrations
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-08-26 17:32:41 -0700
committerUnknwon <u@gogs.io>2016-08-26 17:32:41 -0700
commit37305a59ca0cdc7efe880d4e54f68ecbe3eacc29 (patch)
tree538036c9cd11d34e2166bebf2801e89687c81464 /models/migrations
parentbb359a74f124c759a8de1afbf224b658b57760b7 (diff)
downloadgitea-37305a59ca0cdc7efe880d4e54f68ecbe3eacc29.tar.gz
gitea-37305a59ca0cdc7efe880d4e54f68ecbe3eacc29.zip
migrations: sync table first
Diffstat (limited to 'models/migrations')
-rw-r--r--models/migrations/migrations.go2
-rw-r--r--models/migrations/v14.go10
2 files changed, 9 insertions, 3 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go
index 5f18960769..42d93edd03 100644
--- a/models/migrations/migrations.go
+++ b/models/migrations/migrations.go
@@ -245,7 +245,7 @@ func issueToIssueLabel(x *xorm.Engine) error {
}
if err = sess.Sync2(new(IssueLabel)); err != nil {
- return fmt.Errorf("sync2: %v", err)
+ return fmt.Errorf("Sync2: %v", err)
} else if _, err = sess.Insert(issueLabels); err != nil {
return fmt.Errorf("insert issue-labels: %v", err)
}
diff --git a/models/migrations/v14.go b/models/migrations/v14.go
index 16c497e7e2..79c31133f4 100644
--- a/models/migrations/v14.go
+++ b/models/migrations/v14.go
@@ -10,8 +10,14 @@ import (
"github.com/go-xorm/xorm"
)
-func setCommentUpdatedWithCreated(x *xorm.Engine) error {
- if _, err := x.Exec("UPDATE comment SET updated_unix = created_unix"); err != nil {
+func setCommentUpdatedWithCreated(x *xorm.Engine) (err error) {
+ type Comment struct {
+ UpdatedUnix int64
+ }
+
+ if err = x.Sync2(new(Comment)); err != nil {
+ return fmt.Errorf("Sync2: %v", err)
+ } else if _, err = x.Exec("UPDATE comment SET updated_unix = created_unix"); err != nil {
return fmt.Errorf("set update_unix: %v", err)
}
return nil