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