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.

v150.go 932B

123456789101112131415161718192021222324252627282930313233343536373839
  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 addPrimaryKeyToRepoTopic(x *xorm.Engine) error {
  10. // Topic represents a topic of repositories
  11. type Topic struct {
  12. ID int64 `xorm:"pk autoincr"`
  13. Name string `xorm:"UNIQUE VARCHAR(25)"`
  14. RepoCount int
  15. CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
  16. UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
  17. }
  18. // RepoTopic represents associated repositories and topics
  19. type RepoTopic struct {
  20. RepoID int64 `xorm:"pk"`
  21. TopicID int64 `xorm:"pk"`
  22. }
  23. sess := x.NewSession()
  24. defer sess.Close()
  25. if err := sess.Begin(); err != nil {
  26. return err
  27. }
  28. recreateTable(sess, &Topic{})
  29. recreateTable(sess, &RepoTopic{})
  30. return sess.Commit()
  31. }