added index to IssueDependency

This commit is contained in:
Tim-Niclas Oelschläger 2024-03-04 23:25:46 +01:00 committed by Lunny Xiao
parent 40c3343016
commit 611cccb471
3 changed files with 21 additions and 2 deletions

View File

@ -107,8 +107,8 @@ func (err ErrUnknownDependencyType) Unwrap() error {
type IssueDependency struct {
ID int64 `xorm:"pk autoincr"`
UserID int64 `xorm:"NOT NULL"`
IssueID int64 `xorm:"UNIQUE(issue_dependency) NOT NULL"`
DependencyID int64 `xorm:"UNIQUE(issue_dependency) NOT NULL"`
IssueID int64 `xorm:"UNIQUE(issue_dependency) NOT NULL index"`
DependencyID int64 `xorm:"UNIQUE(issue_dependency) NOT NULL index"`
CreatedUnix timeutil.TimeStamp `xorm:"created"`
UpdatedUnix timeutil.TimeStamp `xorm:"updated"`
}

View File

@ -566,6 +566,8 @@ var migrations = []Migration{
NewMigration("Add default_wiki_branch to repository table", v1_22.AddDefaultWikiBranch),
// v290 -> v291
NewMigration("Add PayloadVersion to HookTask", v1_22.AddPayloadVersionToHookTaskTable),
// v291 -> v292
NewMigration("Add indecies to IssueDependency", v1_22.AddIndeciesToIssueDepencencies),
}
// GetCurrentDBVersion returns the current db version

View File

@ -0,0 +1,17 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package v1_22 //nolint
import (
"xorm.io/xorm"
)
func AddIndeciesToIssueDepencencies(x *xorm.Engine) error {
type IssueDependency struct {
IssueID int64 `xorm:"UNIQUE(issue_dependency) NOT NULL index"`
DependencyID int64 `xorm:"UNIQUE(issue_dependency) NOT NULL index"`
}
return x.Sync(&IssueDependency{})
}