gitea源码

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