mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-12-11 22:11:58 +01:00
cf323a3d55
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
19 lines
554 B
Go
19 lines
554 B
Go
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package forgejo_migrations //nolint:revive
|
|
|
|
import "xorm.io/xorm"
|
|
|
|
func AddPurposeToForgejoAuthToken(x *xorm.Engine) error {
|
|
type ForgejoAuthToken struct {
|
|
ID int64 `xorm:"pk autoincr"`
|
|
Purpose string `xorm:"NOT NULL DEFAULT 'long_term_authorization'"`
|
|
}
|
|
if err := x.Sync(new(ForgejoAuthToken)); err != nil {
|
|
return err
|
|
}
|
|
|
|
_, err := x.Exec("UPDATE `forgejo_auth_token` SET purpose = 'long_term_authorization' WHERE purpose = ''")
|
|
return err
|
|
}
|