migrations: sync table first

pull/197/head
Unknwon 8 years ago
parent bb359a74f1
commit 37305a59ca
  1. 2
      models/migrations/migrations.go
  2. 10
      models/migrations/v14.go

@ -245,7 +245,7 @@ func issueToIssueLabel(x *xorm.Engine) error {
} }
if err = sess.Sync2(new(IssueLabel)); err != nil { 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 { } else if _, err = sess.Insert(issueLabels); err != nil {
return fmt.Errorf("insert issue-labels: %v", err) return fmt.Errorf("insert issue-labels: %v", err)
} }

@ -10,8 +10,14 @@ import (
"github.com/go-xorm/xorm" "github.com/go-xorm/xorm"
) )
func setCommentUpdatedWithCreated(x *xorm.Engine) error { func setCommentUpdatedWithCreated(x *xorm.Engine) (err error) {
if _, err := x.Exec("UPDATE comment SET updated_unix = created_unix"); err != nil { 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 fmt.Errorf("set update_unix: %v", err)
} }
return nil return nil

Loading…
Cancel
Save