diff --git a/models/issues/dependency.go b/models/issues/dependency.go index 146dd1887d..842556c2dc 100644 --- a/models/issues/dependency.go +++ b/models/issues/dependency.go @@ -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"` } diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index ce77432db4..0a21308f5f 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -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 diff --git a/models/migrations/v1_22/v291.go b/models/migrations/v1_22/v291.go new file mode 100644 index 0000000000..69a74bea4c --- /dev/null +++ b/models/migrations/v1_22/v291.go @@ -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{}) +}