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.

v159.go 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2020 The Gitea 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. "code.gitea.io/gitea/modules/timeutil"
  7. "xorm.io/xorm"
  8. )
  9. func updateReactionConstraint(x *xorm.Engine) error {
  10. // Reaction represents a reactions on issues and comments.
  11. type Reaction struct {
  12. ID int64 `xorm:"pk autoincr"`
  13. Type string `xorm:"INDEX UNIQUE(s) NOT NULL"`
  14. IssueID int64 `xorm:"INDEX UNIQUE(s) NOT NULL"`
  15. CommentID int64 `xorm:"INDEX UNIQUE(s)"`
  16. UserID int64 `xorm:"INDEX UNIQUE(s) NOT NULL"`
  17. OriginalAuthorID int64 `xorm:"INDEX UNIQUE(s) NOT NULL DEFAULT(0)"`
  18. OriginalAuthor string `xorm:"INDEX UNIQUE(s)"`
  19. CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
  20. }
  21. sess := x.NewSession()
  22. defer sess.Close()
  23. if err := sess.Begin(); err != nil {
  24. return err
  25. }
  26. if err := recreateTable(sess, &Reaction{}); err != nil {
  27. return err
  28. }
  29. return sess.Commit()
  30. }