This commit is contained in:
JakobDev 2024-05-17 23:19:47 +02:00
parent fac0913d35
commit 6989c44f47
2 changed files with 37 additions and 2 deletions

View File

@ -67,9 +67,9 @@ var migrations = []*Migration{
// v14 -> v15
NewMigration("Remove Gitea-specific columns from the repository and badge tables", RemoveGiteaSpecificColumnsFromRepositoryAndBadge),
// v15 -> v16
NewMigration("Add star lists", AddStarLists),
// v15 -> v17
NewMigration("Create the `federation_host` table", CreateFederationHostTable),
// v16 -> v17
NewMigration("Add star lists", AddStarLists),
}
// GetCurrentDBVersion returns the current Forgejo database version.

View File

@ -0,0 +1,35 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package forgejo_migrations //nolint:revive
import (
"code.gitea.io/gitea/modules/timeutil"
"xorm.io/xorm"
)
func AddStarLists(x *xorm.Engine) error {
type StarList struct {
ID int64 `xorm:"pk autoincr"`
UserID int64 `xorm:"INDEX UNIQUE(name)"`
Name string `xorm:"INDEX UNIQUE(name)"`
Description string
IsPrivate bool
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
}
err := x.Sync(&StarList{})
if err != nil {
return err
}
type StarListRepos struct {
ID int64 `xorm:"pk autoincr"`
StarListID int64 `xorm:"INDEX UNIQUE(repo)"`
RepoID int64 `xorm:"INDEX UNIQUE(repo)"`
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
}
return x.Sync(&StarListRepos{})
}