gitea源码

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package v1_14
  4. import (
  5. "fmt"
  6. "xorm.io/xorm"
  7. )
  8. // OAuth2Grant here is a snapshot of models.OAuth2Grant for this version
  9. // of the database, as it does not appear to have been added as a part
  10. // of a previous migration.
  11. type OAuth2Grant struct {
  12. ID int64 `xorm:"pk autoincr"`
  13. UserID int64 `xorm:"INDEX unique(user_application)"`
  14. ApplicationID int64 `xorm:"INDEX unique(user_application)"`
  15. Counter int64 `xorm:"NOT NULL DEFAULT 1"`
  16. Scope string `xorm:"TEXT"`
  17. Nonce string `xorm:"TEXT"`
  18. CreatedUnix int64 `xorm:"created"`
  19. UpdatedUnix int64 `xorm:"updated"`
  20. }
  21. // TableName sets the database table name to be the correct one, as the
  22. // autogenerated table name for this struct is "o_auth2_grant".
  23. func (grant *OAuth2Grant) TableName() string {
  24. return "oauth2_grant"
  25. }
  26. func AddScopeAndNonceColumnsToOAuth2Grant(x *xorm.Engine) error {
  27. if err := x.Sync(new(OAuth2Grant)); err != nil {
  28. return fmt.Errorf("Sync: %w", err)
  29. }
  30. return nil
  31. }