v14.go 580 B

123456789101112131415161718192021222324
  1. // Copyright 2016 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package migrations
  5. import (
  6. "fmt"
  7. "github.com/go-xorm/xorm"
  8. )
  9. func setCommentUpdatedWithCreated(x *xorm.Engine) (err error) {
  10. type Comment struct {
  11. UpdatedUnix int64
  12. }
  13. if err = x.Sync2(new(Comment)); err != nil {
  14. return fmt.Errorf("Sync2: %v", err)
  15. } else if _, err = x.Exec("UPDATE comment SET updated_unix = created_unix"); err != nil {
  16. return fmt.Errorf("set update_unix: %v", err)
  17. }
  18. return nil
  19. }