code.gitea.io/gitea@v1.21.7/models/migrations/v1_19/v239.go (about) 1 // Copyright 2022 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package v1_19 //nolint 5 6 import ( 7 "xorm.io/xorm" 8 ) 9 10 func AddScopeForAccessTokens(x *xorm.Engine) error { 11 type AccessToken struct { 12 Scope string 13 } 14 15 if err := x.Sync(new(AccessToken)); err != nil { 16 return err 17 } 18 19 // all previous tokens have `all` and `sudo` scopes 20 _, err := x.Exec("UPDATE access_token SET scope = ? WHERE scope IS NULL OR scope = ''", "all,sudo") 21 return err 22 }