Added migrations for User and FederatedUser

This commit is contained in:
Clemens 2024-05-16 10:26:51 +02:00
parent 1b3c4dcd85
commit 6457ace318
3 changed files with 35 additions and 0 deletions

View file

@ -68,6 +68,10 @@ var migrations = []*Migration{
NewMigration("Remove Gitea-specific columns from the repository and badge tables", RemoveGiteaSpecificColumnsFromRepositoryAndBadge),
// v15 -> v16
NewMigration("Create the `federation_host` table", CreateFederationHostTable),
// v16 -> v17
NewMigration("Create the `federated_user` table", CreateFederatedUserTable),
// v17 -> v18
NewMigration("Add `normalized_federated_uri` column to `user` table", AddNormalizedFederatedURIToUser),
}
// GetCurrentDBVersion returns the current Forgejo database version.

View file

@ -0,0 +1,17 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package forgejo_migrations //nolint:revive
import "xorm.io/xorm"
type FederatedUser struct {
ID int64 `xorm:"pk autoincr"`
UserID int64 `xorm:"NOT NULL"`
ExternalID string `xorm:"UNIQUE(federation_user_mapping) NOT NULL"`
FederationHostID int64 `xorm:"UNIQUE(federation_user_mapping) NOT NULL"`
}
func CreateFederatedUserTable(x *xorm.Engine) error {
return x.Sync(new(FederatedUser))
}

View file

@ -0,0 +1,14 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package forgejo_migrations //nolint:revive
import "xorm.io/xorm"
func AddNormalizedFederatedURIToUser(x *xorm.Engine) error {
type User struct {
ID int64 `xorm:"pk autoincr"`
NormalizedFederatedURI string
}
return x.Sync(&User{})
}