gitea

Development moved to Codeberg

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package v1_14 //nolint

import (
	"fmt"

	"xorm.io/xorm"
)

// OAuth2Grant here is a snapshot of models.OAuth2Grant for this version
// of the database, as it does not appear to have been added as a part
// of a previous migration.
type OAuth2Grant struct {
	ID            int64  `xorm:"pk autoincr"`
	UserID        int64  `xorm:"INDEX unique(user_application)"`
	ApplicationID int64  `xorm:"INDEX unique(user_application)"`
	Counter       int64  `xorm:"NOT NULL DEFAULT 1"`
	Scope         string `xorm:"TEXT"`
	Nonce         string `xorm:"TEXT"`
	CreatedUnix   int64  `xorm:"created"`
	UpdatedUnix   int64  `xorm:"updated"`
}

// TableName sets the database table name to be the correct one, as the
// autogenerated table name for this struct is "o_auth2_grant".
func (grant *OAuth2Grant) TableName() string {
	return "oauth2_grant"
}

func AddScopeAndNonceColumnsToOAuth2Grant(x *xorm.Engine) error {
	if err := x.Sync2(new(OAuth2Grant)); err != nil {
		return fmt.Errorf("Sync2: %w", err)
	}
	return nil
}