2021-01-01 11:33:27 -05:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
2022-11-27 13:20:29 -05:00
|
|
|
// SPDX-License-Identifier: MIT
|
2021-01-01 11:33:27 -05:00
|
|
|
|
2022-11-02 03:54:36 -05:00
|
|
|
package v1_14 //nolint
|
2021-01-01 11:33:27 -05:00
|
|
|
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
2022-11-02 03:54:36 -05:00
|
|
|
func AddScopeAndNonceColumnsToOAuth2Grant(x *xorm.Engine) error {
|
2021-01-01 11:33:27 -05:00
|
|
|
if err := x.Sync2(new(OAuth2Grant)); err != nil {
|
2022-10-24 14:29:17 -05:00
|
|
|
return fmt.Errorf("Sync2: %w", err)
|
2021-01-01 11:33:27 -05:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|