aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-09-28 22:58:35 +0200
committerGitHub <noreply@github.com>2023-09-28 22:58:35 +0200
commit9d9cebc5e7da242245bd2418a43cc7f294fb485b (patch)
tree627a351668ca6ff1929995f2ad65505c6f02ec79 /models
parent3fcad582c9b9bfe66f4a346652f82b1aaf18430d (diff)
downloadgitea-9d9cebc5e7da242245bd2418a43cc7f294fb485b.tar.gz
gitea-9d9cebc5e7da242245bd2418a43cc7f294fb485b.zip
Add Index to `comment.dependent_issue_id` (#27325)
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: Giteabot <teabot@gitea.io>
Diffstat (limited to 'models')
-rw-r--r--models/issues/comment.go2
-rw-r--r--models/migrations/migrations.go2
-rw-r--r--models/migrations/v1_21/v278.go16
3 files changed, 19 insertions, 1 deletions
diff --git a/models/issues/comment.go b/models/issues/comment.go
index 66b3a8527f..8b1b18051e 100644
--- a/models/issues/comment.go
+++ b/models/issues/comment.go
@@ -246,7 +246,7 @@ type Comment struct {
NewTitle string
OldRef string
NewRef string
- DependentIssueID int64
+ DependentIssueID int64 `xorm:"index"` // This is used by issue_service.deleteIssue
DependentIssue *Issue `xorm:"-"`
CommitID int64
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go
index 38fff37bed..4527bcc1ae 100644
--- a/models/migrations/migrations.go
+++ b/models/migrations/migrations.go
@@ -536,6 +536,8 @@ var migrations = []Migration{
NewMigration("Add RemoteAddress to mirrors", v1_21.AddRemoteAddressToMirrors),
// v277 -> v278
NewMigration("Add Index to issue_user.issue_id", v1_21.AddIndexToIssueUserIssueID),
+ // v278 -> v279
+ NewMigration("Add Index to comment.dependent_issue_id", v1_21.AddIndexToCommentDependentIssueID),
}
// GetCurrentDBVersion returns the current db version
diff --git a/models/migrations/v1_21/v278.go b/models/migrations/v1_21/v278.go
new file mode 100644
index 0000000000..d6a462d1e7
--- /dev/null
+++ b/models/migrations/v1_21/v278.go
@@ -0,0 +1,16 @@
+// Copyright 2023 The Gitea Authors. All rights reserved.
+// SPDX-License-Identifier: MIT
+
+package v1_21 //nolint
+
+import (
+ "xorm.io/xorm"
+)
+
+func AddIndexToCommentDependentIssueID(x *xorm.Engine) error {
+ type Comment struct {
+ DependentIssueID int64 `xorm:"index"`
+ }
+
+ return x.Sync(new(Comment))
+}