2020-11-11 07:37:11 +09:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
2022-11-28 03:20:29 +09:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-11-11 07:37:11 +09:00
|
|
|
|
2022-11-02 17:54:36 +09:00
|
|
|
package v1_14 //nolint
|
2020-11-11 07:37:11 +09:00
|
|
|
|
|
|
|
import (
|
2022-11-02 17:54:36 +09:00
|
|
|
"code.gitea.io/gitea/models/migrations/base"
|
2020-11-11 07:37:11 +09:00
|
|
|
"code.gitea.io/gitea/modules/timeutil"
|
|
|
|
|
|
|
|
"xorm.io/xorm"
|
|
|
|
)
|
|
|
|
|
2022-11-02 17:54:36 +09:00
|
|
|
func UpdateReactionConstraint(x *xorm.Engine) error {
|
2020-11-11 07:37:11 +09:00
|
|
|
// Reaction represents a reactions on issues and comments.
|
|
|
|
type Reaction struct {
|
|
|
|
ID int64 `xorm:"pk autoincr"`
|
|
|
|
Type string `xorm:"INDEX UNIQUE(s) NOT NULL"`
|
|
|
|
IssueID int64 `xorm:"INDEX UNIQUE(s) NOT NULL"`
|
|
|
|
CommentID int64 `xorm:"INDEX UNIQUE(s)"`
|
|
|
|
UserID int64 `xorm:"INDEX UNIQUE(s) NOT NULL"`
|
|
|
|
OriginalAuthorID int64 `xorm:"INDEX UNIQUE(s) NOT NULL DEFAULT(0)"`
|
|
|
|
OriginalAuthor string `xorm:"INDEX UNIQUE(s)"`
|
|
|
|
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
|
|
|
|
}
|
|
|
|
|
|
|
|
sess := x.NewSession()
|
|
|
|
defer sess.Close()
|
|
|
|
|
|
|
|
if err := sess.Begin(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-11-02 17:54:36 +09:00
|
|
|
if err := base.RecreateTable(sess, &Reaction{}); err != nil {
|
2020-11-11 07:37:11 +09:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return sess.Commit()
|
|
|
|
}
|