From cf323a3d55e11f2eb5834e36a5af69157e6b45de Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 16 Nov 2024 10:53:46 +0100 Subject: [PATCH] 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 --- models/auth/auth_token.go | 2 +- models/forgejo_migrations/v24.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/models/auth/auth_token.go b/models/auth/auth_token.go index 8955b57a4f..c64af3e41f 100644 --- a/models/auth/auth_token.go +++ b/models/auth/auth_token.go @@ -39,7 +39,7 @@ type AuthorizationToken struct { UID int64 `xorm:"INDEX"` LookupKey string `xorm:"INDEX UNIQUE"` HashedValidator string - Purpose AuthorizationPurpose `xorm:"NOT NULL"` + Purpose AuthorizationPurpose `xorm:"NOT NULL DEFAULT 'long_term_authorization'"` Expiry timeutil.TimeStamp } diff --git a/models/forgejo_migrations/v24.go b/models/forgejo_migrations/v24.go index 8c751e3f5f..ebfb5fc1c4 100644 --- a/models/forgejo_migrations/v24.go +++ b/models/forgejo_migrations/v24.go @@ -8,7 +8,7 @@ import "xorm.io/xorm" func AddPurposeToForgejoAuthToken(x *xorm.Engine) error { type ForgejoAuthToken struct { 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 { return err