migrations: add FederationHost; add FederatedUser

This commit is contained in:
famfo 2025-03-30 20:14:47 +02:00
parent 7d4e2f1ce2
commit afbd4d8d77
No known key found for this signature in database
2 changed files with 31 additions and 0 deletions

View file

@ -94,6 +94,8 @@ var migrations = []*Migration{
NewMigration("Add `created_unix` column to `user_redirect` table", AddCreatedUnixToRedirect),
// v27 -> v28
NewMigration("Add pronoun privacy settings to user", AddHidePronounsOptionToUser),
// v28 -> v29
NewMigration("Add public key information to `FederatedUser` and `FederationHost`", AddPublicKeyInformationForFederation),
}
// GetCurrentDBVersion returns the current Forgejo database version.

View file

@ -0,0 +1,29 @@
// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package forgejo_migrations //nolint:revive
import (
"database/sql"
"xorm.io/xorm"
)
func AddPublicKeyInformationForFederation(x *xorm.Engine) error {
type FederationHost struct {
KeyID sql.NullString `xorm:"key_id UNIQUE"`
PublicKey sql.Null[sql.RawBytes] `xorm:"BLOB"`
}
err := x.Sync(&FederationHost{})
if err != nil {
return err
}
type FederatedUser struct {
KeyID sql.NullString `xorm:"key_id UNIQUE"`
PublicKey sql.Null[sql.RawBytes] `xorm:"BLOB"`
}
return x.Sync(&FederatedUser{})
}