You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

v164.go 1.1KB

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