aboutsummaryrefslogtreecommitdiffstats
path: root/models/topic.go
diff options
context:
space:
mode:
authorAlexey Terentyev <axifnx@gmail.com>2018-06-27 08:23:10 +0300
committertechknowlogick <techknowlogick@users.noreply.github.com>2018-06-27 01:23:10 -0400
commit91ff87c0e5caf9790cff7d2683b95a10250edcc2 (patch)
tree927d7880169ae035fe7fef3067d048371eff71d5 /models/topic.go
parenta9ffbeb6791089b5ef04f5c1156f8b8cb0012d92 (diff)
downloadgitea-91ff87c0e5caf9790cff7d2683b95a10250edcc2.tar.gz
gitea-91ff87c0e5caf9790cff7d2683b95a10250edcc2.zip
Fixed violation of the unique constraint for v68 migration (#4297)
Diffstat (limited to 'models/topic.go')
-rw-r--r--models/topic.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/models/topic.go b/models/topic.go
index 247aac5fff..678795a3db 100644
--- a/models/topic.go
+++ b/models/topic.go
@@ -26,7 +26,7 @@ var topicPattern = regexp.MustCompile(`^[a-z0-9][a-z0-9-]*$`)
// Topic represents a topic of repositories
type Topic struct {
ID int64
- Name string `xorm:"unique"`
+ Name string `xorm:"UNIQUE"`
RepoCount int
CreatedUnix util.TimeStamp `xorm:"INDEX created"`
UpdatedUnix util.TimeStamp `xorm:"INDEX updated"`
@@ -34,8 +34,8 @@ type Topic struct {
// RepoTopic represents associated repositories and topics
type RepoTopic struct {
- RepoID int64 `xorm:"unique(s)"`
- TopicID int64 `xorm:"unique(s)"`
+ RepoID int64 `xorm:"UNIQUE(s)"`
+ TopicID int64 `xorm:"UNIQUE(s)"`
}
// ErrTopicNotExist represents an error that a topic is not exist
@@ -190,10 +190,10 @@ func SaveTopics(repoID int64, topicNames ...string) error {
}
}
- topicNames = topicNames[:0]
+ topicNames = make([]string, 0, 25)
if err := sess.Table("topic").Cols("name").
- Join("INNER", "repo_topic", "topic.id = repo_topic.topic_id").
- Where("repo_topic.repo_id = ?", repoID).Find(&topicNames); err != nil {
+ Join("INNER", "repo_topic", "repo_topic.topic_id = topic.id").
+ Where("repo_topic.repo_id = ?", repoID).Desc("topic.repo_count").Find(&topicNames); err != nil {
return err
}