diff options
author | Unknwon <u@gogs.io> | 2016-08-26 17:32:41 -0700 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-08-26 17:32:41 -0700 |
commit | 37305a59ca0cdc7efe880d4e54f68ecbe3eacc29 (patch) | |
tree | 538036c9cd11d34e2166bebf2801e89687c81464 /models/migrations/v14.go | |
parent | bb359a74f124c759a8de1afbf224b658b57760b7 (diff) | |
download | gitea-37305a59ca0cdc7efe880d4e54f68ecbe3eacc29.tar.gz gitea-37305a59ca0cdc7efe880d4e54f68ecbe3eacc29.zip |
migrations: sync table first
Diffstat (limited to 'models/migrations/v14.go')
-rw-r--r-- | models/migrations/v14.go | 10 |
1 files changed, 8 insertions, 2 deletions
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 |