From 611cccb471b83b39db73e32f39472c193d79740b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Niclas=20Oelschl=C3=A4ger?= Date: Mon, 4 Mar 2024 23:25:46 +0100 Subject: [PATCH] added index to IssueDependency --- models/issues/dependency.go | 4 ++-- models/migrations/migrations.go | 2 ++ models/migrations/v1_22/v291.go | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 models/migrations/v1_22/v291.go 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{}) +}