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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. "fmt"
  7. "code.gitea.io/gitea/modules/timeutil"
  8. "xorm.io/xorm"
  9. )
  10. func addLanguageStats(x *xorm.Engine) error {
  11. // LanguageStat see models/repo_language_stats.go
  12. type LanguageStat struct {
  13. ID int64 `xorm:"pk autoincr"`
  14. RepoID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"`
  15. CommitID string
  16. IsPrimary bool
  17. Language string `xorm:"VARCHAR(30) UNIQUE(s) INDEX NOT NULL"`
  18. Percentage float32 `xorm:"NUMERIC(5,2) NOT NULL DEFAULT 0"`
  19. Color string `xorm:"-"`
  20. CreatedUnix timeutil.TimeStamp `xorm:"INDEX CREATED"`
  21. }
  22. type RepoIndexerType int
  23. // RepoIndexerStatus see models/repo_stats_indexer.go
  24. type RepoIndexerStatus struct {
  25. ID int64 `xorm:"pk autoincr"`
  26. RepoID int64 `xorm:"INDEX(s)"`
  27. CommitSha string `xorm:"VARCHAR(40)"`
  28. IndexerType RepoIndexerType `xorm:"INDEX(s) NOT NULL DEFAULT 0"`
  29. }
  30. if err := x.Sync2(new(LanguageStat)); err != nil {
  31. return fmt.Errorf("Sync2: %v", err)
  32. }
  33. if err := x.Sync2(new(RepoIndexerStatus)); err != nil {
  34. return fmt.Errorf("Sync2: %v", err)
  35. }
  36. return nil
  37. }