fix merge

This commit is contained in:
wxiaoguang 2022-09-29 16:30:17 +08:00 committed by Jason Song
parent fb738c4192
commit 5f0cb6b9e5
2 changed files with 65 additions and 0 deletions

View File

@ -443,6 +443,10 @@ var migrations = []Migration{
NewMigration("Add package cleanup rule table", v1_19.CreatePackageCleanupRuleTable),
// v235 -> v236
NewMigration("Add index for access_token", v1_19.AddIndexForAccessToken),
// in dev
NewMigration("Add bots tables", addBotTables),
}
// GetCurrentDBVersion returns the current db version

View File

@ -0,0 +1,61 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package migrations
import (
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/timeutil"
"xorm.io/xorm"
)
func addBotTables(x *xorm.Engine) error {
type BotsRunner struct {
ID int64
UUID string `xorm:"CHAR(36) UNIQUE"`
Name string `xorm:"VARCHAR(32) UNIQUE"`
OS string `xorm:"VARCHAR(16) index"` // the runner running os
Arch string `xorm:"VARCHAR(16) index"` // the runner running architecture
Type string `xorm:"VARCHAR(16)"`
OwnerID int64 `xorm:"index"` // org level runner, 0 means system
RepoID int64 `xorm:"index"` // repo level runner, if orgid also is zero, then it's a global
Description string `xorm:"TEXT"`
Base int // 0 native 1 docker 2 virtual machine
RepoRange string // glob match which repositories could use this runner
Token string
LastOnline timeutil.TimeStamp `xorm:"index"`
Created timeutil.TimeStamp `xorm:"created"`
}
type BotsBuild struct {
ID int64
Title string
UUID string `xorm:"CHAR(36)"`
Index int64 `xorm:"index unique(repo_index)"`
RepoID int64 `xorm:"index unique(repo_index)"`
TriggerUserID int64
Ref string
CommitSHA string
Event string
Token string // token for this task
Grant string // permissions for this task
EventPayload string `xorm:"LONGTEXT"`
RunnerID int64 `xorm:"index"`
Status int `xorm:"index"`
Created timeutil.TimeStamp `xorm:"created"`
StartTime timeutil.TimeStamp
EndTime timeutil.TimeStamp
Updated timeutil.TimeStamp `xorm:"updated"`
}
type Repository struct {
NumBuilds int `xorm:"NOT NULL DEFAULT 0"`
NumClosedBuilds int `xorm:"NOT NULL DEFAULT 0"`
}
type BotsBuildIndex db.ResourceIndex
return x.Sync2(new(BotsRunner), new(BotsBuild), new(Repository), new(BotsBuildIndex))
}