Skip to content

Commit 7ea7f2b

Browse files
GiteaBotJakobDev
andauthored
Add Index to comment.dependent_issue_id (go-gitea#27325) (go-gitea#27340)
Backport go-gitea#27325 by @JakobDev This Column is missing index. It is used by [issue_service.deleteIssue](https://github.com/go-gitea/gitea/blob/7ea2a910cebaf51cfd13c0941029c404e408ae54/services/issue/issue.go#L300). Co-authored-by: JakobDev <[email protected]>
1 parent c61b9c5 commit 7ea7f2b

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

models/issues/comment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ type Comment struct {
246246
NewTitle string
247247
OldRef string
248248
NewRef string
249-
DependentIssueID int64
249+
DependentIssueID int64 `xorm:"index"` // This is used by issue_service.deleteIssue
250250
DependentIssue *Issue `xorm:"-"`
251251

252252
CommitID int64

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,8 @@ var migrations = []Migration{
536536
NewMigration("Add RemoteAddress to mirrors", v1_21.AddRemoteAddressToMirrors),
537537
// v277 -> v278
538538
NewMigration("Add Index to issue_user.issue_id", v1_21.AddIndexToIssueUserIssueID),
539+
// v278 -> v279
540+
NewMigration("Add Index to comment.dependent_issue_id", v1_21.AddIndexToCommentDependentIssueID),
539541
}
540542

541543
// GetCurrentDBVersion returns the current db version

models/migrations/v1_21/v278.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_21 //nolint
5+
6+
import (
7+
"xorm.io/xorm"
8+
)
9+
10+
func AddIndexToCommentDependentIssueID(x *xorm.Engine) error {
11+
type Comment struct {
12+
DependentIssueID int64 `xorm:"index"`
13+
}
14+
15+
return x.Sync(new(Comment))
16+
}

0 commit comments

Comments
 (0)