diff --git a/models/bots/runner_token.go b/models/bots/runner_token.go index c764b2f54a..42cdadbbdb 100644 --- a/models/bots/runner_token.go +++ b/models/bots/runner_token.go @@ -29,7 +29,7 @@ func (err ErrRunnerTokenNotExist) Error() string { // RunnerToken represents runner tokens type RunnerToken struct { ID int64 - Token string `xorm:"CHAR(36) UNIQUE"` + Token string `xorm:"UNIQUE"` OwnerID int64 `xorm:"index"` // org level runner, 0 means system Owner *user_model.User `xorm:"-"` RepoID int64 `xorm:"index"` // repo level runner, if orgid also is zero, then it's a global @@ -81,8 +81,7 @@ func NewRunnerToken(ownerID, repoID int64) (*RunnerToken, error) { OwnerID: ownerID, RepoID: repoID, IsActive: false, - // FIXME: why token is 36 chars? - Token: base.EncodeSha1(gouuid.New().String())[:36], + Token: base.EncodeSha1(gouuid.New().String()), } _, err := db.GetEngine(db.DefaultContext).Insert(runnerToken) return runnerToken, err diff --git a/models/migrations/v-dev.go b/models/migrations/v-dev.go index bfc90e6e9a..4702f9c0d9 100644 --- a/models/migrations/v-dev.go +++ b/models/migrations/v-dev.go @@ -21,7 +21,11 @@ func addBotTables(x *xorm.Engine) error { 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 `xorm:"CHAR(36) UNIQUE"` + + Token string `xorm:"-"` + TokenHash string `xorm:"UNIQUE"` // sha256 of token + TokenSalt string + // TokenLastEight string `xorm:"token_last_eight"` // it's unnecessary because we don't find runners by token // instance status (idle, active, offline) Status int32 @@ -38,7 +42,7 @@ func addBotTables(x *xorm.Engine) error { type BotsRunnerToken struct { ID int64 - Token string `xorm:"CHAR(36) UNIQUE"` + Token string `xorm:"UNIQUE"` 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 IsActive bool