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.

v240.go 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. // Copyright 2022 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package v1_19 //nolint
  4. import (
  5. "code.gitea.io/gitea/models/db"
  6. "code.gitea.io/gitea/modules/timeutil"
  7. "xorm.io/xorm"
  8. )
  9. func AddActionsTables(x *xorm.Engine) error {
  10. type ActionRunner struct {
  11. ID int64
  12. UUID string `xorm:"CHAR(36) UNIQUE"`
  13. Name string `xorm:"VARCHAR(255)"`
  14. OwnerID int64 `xorm:"index"` // org level runner, 0 means system
  15. RepoID int64 `xorm:"index"` // repo level runner, if orgid also is zero, then it's a global
  16. Description string `xorm:"TEXT"`
  17. Base int // 0 native 1 docker 2 virtual machine
  18. RepoRange string // glob match which repositories could use this runner
  19. Token string `xorm:"-"`
  20. TokenHash string `xorm:"UNIQUE"` // sha256 of token
  21. TokenSalt string
  22. // TokenLastEight string `xorm:"token_last_eight"` // it's unnecessary because we don't find runners by token
  23. LastOnline timeutil.TimeStamp `xorm:"index"`
  24. LastActive timeutil.TimeStamp `xorm:"index"`
  25. // Store OS and Artch.
  26. AgentLabels []string
  27. // Store custom labes use defined.
  28. CustomLabels []string
  29. Created timeutil.TimeStamp `xorm:"created"`
  30. Updated timeutil.TimeStamp `xorm:"updated"`
  31. Deleted timeutil.TimeStamp `xorm:"deleted"`
  32. }
  33. type ActionRunnerToken struct {
  34. ID int64
  35. Token string `xorm:"UNIQUE"`
  36. OwnerID int64 `xorm:"index"` // org level runner, 0 means system
  37. RepoID int64 `xorm:"index"` // repo level runner, if orgid also is zero, then it's a global
  38. IsActive bool
  39. Created timeutil.TimeStamp `xorm:"created"`
  40. Updated timeutil.TimeStamp `xorm:"updated"`
  41. Deleted timeutil.TimeStamp `xorm:"deleted"`
  42. }
  43. type ActionRun struct {
  44. ID int64
  45. Title string
  46. RepoID int64 `xorm:"index unique(repo_index)"`
  47. OwnerID int64 `xorm:"index"`
  48. WorkflowID string `xorm:"index"` // the name of workflow file
  49. Index int64 `xorm:"index unique(repo_index)"` // a unique number for each run of a repository
  50. TriggerUserID int64
  51. Ref string
  52. CommitSHA string
  53. Event string
  54. IsForkPullRequest bool
  55. EventPayload string `xorm:"LONGTEXT"`
  56. Status int `xorm:"index"`
  57. Started timeutil.TimeStamp
  58. Stopped timeutil.TimeStamp
  59. Created timeutil.TimeStamp `xorm:"created"`
  60. Updated timeutil.TimeStamp `xorm:"updated"`
  61. }
  62. type ActionRunJob struct {
  63. ID int64
  64. RunID int64 `xorm:"index"`
  65. RepoID int64 `xorm:"index"`
  66. OwnerID int64 `xorm:"index"`
  67. CommitSHA string `xorm:"index"`
  68. IsForkPullRequest bool
  69. Name string `xorm:"VARCHAR(255)"`
  70. Attempt int64
  71. WorkflowPayload []byte
  72. JobID string `xorm:"VARCHAR(255)"` // job id in workflow, not job's id
  73. Needs []string `xorm:"JSON TEXT"`
  74. RunsOn []string `xorm:"JSON TEXT"`
  75. TaskID int64 // the latest task of the job
  76. Status int `xorm:"index"`
  77. Started timeutil.TimeStamp
  78. Stopped timeutil.TimeStamp
  79. Created timeutil.TimeStamp `xorm:"created"`
  80. Updated timeutil.TimeStamp `xorm:"updated index"`
  81. }
  82. type Repository struct {
  83. NumActionRuns int `xorm:"NOT NULL DEFAULT 0"`
  84. NumClosedActionRuns int `xorm:"NOT NULL DEFAULT 0"`
  85. }
  86. type ActionRunIndex db.ResourceIndex
  87. type ActionTask struct {
  88. ID int64
  89. JobID int64
  90. Attempt int64
  91. RunnerID int64 `xorm:"index"`
  92. Status int `xorm:"index"`
  93. Started timeutil.TimeStamp `xorm:"index"`
  94. Stopped timeutil.TimeStamp
  95. RepoID int64 `xorm:"index"`
  96. OwnerID int64 `xorm:"index"`
  97. CommitSHA string `xorm:"index"`
  98. IsForkPullRequest bool
  99. TokenHash string `xorm:"UNIQUE"` // sha256 of token
  100. TokenSalt string
  101. TokenLastEight string `xorm:"index token_last_eight"`
  102. LogFilename string // file name of log
  103. LogInStorage bool // read log from database or from storage
  104. LogLength int64 // lines count
  105. LogSize int64 // blob size
  106. LogIndexes []int64 `xorm:"LONGBLOB"` // line number to offset
  107. LogExpired bool // files that are too old will be deleted
  108. Created timeutil.TimeStamp `xorm:"created"`
  109. Updated timeutil.TimeStamp `xorm:"updated index"`
  110. }
  111. type ActionTaskStep struct {
  112. ID int64
  113. Name string `xorm:"VARCHAR(255)"`
  114. TaskID int64 `xorm:"index unique(task_index)"`
  115. Index int64 `xorm:"index unique(task_index)"`
  116. RepoID int64 `xorm:"index"`
  117. Status int `xorm:"index"`
  118. LogIndex int64
  119. LogLength int64
  120. Started timeutil.TimeStamp
  121. Stopped timeutil.TimeStamp
  122. Created timeutil.TimeStamp `xorm:"created"`
  123. Updated timeutil.TimeStamp `xorm:"updated"`
  124. }
  125. type dbfsMeta struct {
  126. ID int64 `xorm:"pk autoincr"`
  127. FullPath string `xorm:"VARCHAR(500) UNIQUE NOT NULL"`
  128. BlockSize int64 `xorm:"BIGINT NOT NULL"`
  129. FileSize int64 `xorm:"BIGINT NOT NULL"`
  130. CreateTimestamp int64 `xorm:"BIGINT NOT NULL"`
  131. ModifyTimestamp int64 `xorm:"BIGINT NOT NULL"`
  132. }
  133. type dbfsData struct {
  134. ID int64 `xorm:"pk autoincr"`
  135. Revision int64 `xorm:"BIGINT NOT NULL"`
  136. MetaID int64 `xorm:"BIGINT index(meta_offset) NOT NULL"`
  137. BlobOffset int64 `xorm:"BIGINT index(meta_offset) NOT NULL"`
  138. BlobSize int64 `xorm:"BIGINT NOT NULL"`
  139. BlobData []byte `xorm:"BLOB NOT NULL"`
  140. }
  141. return x.Sync(
  142. new(ActionRunner),
  143. new(ActionRunnerToken),
  144. new(ActionRun),
  145. new(ActionRunJob),
  146. new(Repository),
  147. new(ActionRunIndex),
  148. new(ActionTask),
  149. new(ActionTaskStep),
  150. new(dbfsMeta),
  151. new(dbfsData),
  152. )
  153. }