Skip to content

Commit ed2c68f

Browse files
committed
Merge branch 'feature/27877_combined_index_on_issue_user' of github.com:sebastian-sauer/gitea into sebastian-sauer-feature/27877_combined_index_on_issue_user
2 parents cbf923e + e9561e9 commit ed2c68f

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

models/issues/issue_user.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
// IssueUser represents an issue-user relation.
1515
type IssueUser struct {
1616
ID int64 `xorm:"pk autoincr"`
17-
UID int64 `xorm:"INDEX"` // User ID.
18-
IssueID int64 `xorm:"INDEX"`
17+
UID int64 `xorm:"INDEX unique(uid_to_issue)"` // User ID.
18+
IssueID int64 `xorm:"INDEX unique(uid_to_issue)"`
1919
IsRead bool
2020
IsMentioned bool
2121
}

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ var migrations = []Migration{
550550
NewMigration("Add auth_token table", v1_22.CreateAuthTokenTable),
551551
// v282 -> v283
552552
NewMigration("Add Index to pull_auto_merge.doer_id", v1_22.AddIndexToPullAutoMergeDoerID),
553+
// v283 -> v284
554+
NewMigration("Add combined Index to issue_user.uid and issue_id", v1_22.AddCombinedIndexToIssueUser),
553555
}
554556

555557
// GetCurrentDBVersion returns the current db version

models/migrations/v1_22/v283.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_22 //nolint
5+
6+
import (
7+
"xorm.io/xorm"
8+
)
9+
10+
func AddCombinedIndexToIssueUser(x *xorm.Engine) error {
11+
type IssueUser struct {
12+
UID int64 `xorm:"INDEX unique(uid_to_issue)"` // User ID.
13+
IssueID int64 `xorm:"INDEX unique(uid_to_issue)"`
14+
}
15+
16+
return x.Sync(&IssueUser{})
17+
}

0 commit comments

Comments
 (0)