Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-22 01:44:24 +01:00

fix: extend forgejo_auth_token table (part two)

Add the default value of the purpose field to both the table and the
migration. The table in v9 and v7 backport already have the default
value.

ALTER TABLE `forgejo_auth_token` ADD `purpose` TEXT NOT NULL [] - Cannot add a NOT NULL column with default value NULL
This commit is contained in:
Earl Warren 2024-11-16 10:53:46 +01:00
parent 6bab3c374c
commit cf323a3d55
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
2 changed files with 2 additions and 2 deletions

View file

@ -39,7 +39,7 @@ type AuthorizationToken struct {
UID int64 `xorm:"INDEX"` UID int64 `xorm:"INDEX"`
LookupKey string `xorm:"INDEX UNIQUE"` LookupKey string `xorm:"INDEX UNIQUE"`
HashedValidator string HashedValidator string
Purpose AuthorizationPurpose `xorm:"NOT NULL"` Purpose AuthorizationPurpose `xorm:"NOT NULL DEFAULT 'long_term_authorization'"`
Expiry timeutil.TimeStamp Expiry timeutil.TimeStamp
} }

View file

@ -8,7 +8,7 @@ import "xorm.io/xorm"
func AddPurposeToForgejoAuthToken(x *xorm.Engine) error { func AddPurposeToForgejoAuthToken(x *xorm.Engine) error {
type ForgejoAuthToken struct { type ForgejoAuthToken struct {
ID int64 `xorm:"pk autoincr"` ID int64 `xorm:"pk autoincr"`
Purpose string `xorm:"NOT NULL"` Purpose string `xorm:"NOT NULL DEFAULT 'long_term_authorization'"`
} }
if err := x.Sync(new(ForgejoAuthToken)); err != nil { if err := x.Sync(new(ForgejoAuthToken)); err != nil {
return err return err