You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

v14.go 925B

1234567891011121314151617181920212223242526272829303132333435363738
  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. "xorm.io/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. }
  20. // UserV14 describes the added fields for migrating from v13 -> v14
  21. type UserV14 struct {
  22. DiffViewStyle string `xorm:"NOT NULL DEFAULT ''"`
  23. }
  24. // TableName will be invoked by XORM to customize the table name
  25. func (*UserV14) TableName() string {
  26. return "user"
  27. }
  28. func createUserColumnDiffViewStyle(x *xorm.Engine) error {
  29. return x.Sync2(new(UserV14))
  30. }