From 37305a59ca0cdc7efe880d4e54f68ecbe3eacc29 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 26 Aug 2016 17:32:41 -0700 Subject: [PATCH] migrations: sync table first --- models/migrations/migrations.go | 2 +- models/migrations/v14.go | 10 ++++++++-- 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