Add Primary Key to Topic and RepoTopic (#12639)

Add a primary key to Topic and RepoTopic tables

Fix #8920

Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
zeripath
2020-09-10 20:45:01 +01:00
committed by GitHub
parent 4f8dad37f8
commit 47289344e2
3 changed files with 44 additions and 3 deletions

View File

@ -25,7 +25,7 @@ var topicPattern = regexp.MustCompile(`^[a-z0-9][a-z0-9-]*$`)
// Topic represents a topic of repositories
type Topic struct {
ID int64
ID int64 `xorm:"pk autoincr"`
Name string `xorm:"UNIQUE VARCHAR(25)"`
RepoCount int
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
@ -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:"pk"`
TopicID int64 `xorm:"pk"`
}
// ErrTopicNotExist represents an error that a topic is not exist