Skip to content

Commit

Permalink
Add Index to pull_auto_merge.doer_id (#27811)
Browse files Browse the repository at this point in the history
Reported at https://codeberg.org/forgejo/forgejo/issues/1677

This column is used by
[deleteUser](https://github.com/go-gitea/gitea/blob/f089be91da44ee3e85fbe326a204c7c8a5df3d31/services/user/delete.go#L90).

Note: This PR contains a Migration, so we can't backport it to 1.21.
  • Loading branch information
JakobDev authored Oct 30, 2023
1 parent 0a71013 commit c8602a8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions models/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,8 @@ var migrations = []Migration{
NewMigration("Rename user themes", v1_22.RenameUserThemes),
// v281 -> v282
NewMigration("Add auth_token table", v1_22.CreateAuthTokenTable),
// v282 -> v283
NewMigration("Add Index to pull_auto_merge.doer_id", v1_22.AddIndexToPullAutoMergeDoerID),
}

// GetCurrentDBVersion returns the current db version
Expand Down
16 changes: 16 additions & 0 deletions models/migrations/v1_22/v282.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package v1_22 //nolint

import (
"xorm.io/xorm"
)

func AddIndexToPullAutoMergeDoerID(x *xorm.Engine) error {
type PullAutoMerge struct {
DoerID int64 `xorm:"INDEX NOT NULL"`
}

return x.Sync(&PullAutoMerge{})
}
2 changes: 1 addition & 1 deletion models/pull/automerge.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
type AutoMerge struct {
ID int64 `xorm:"pk autoincr"`
PullID int64 `xorm:"UNIQUE"`
DoerID int64 `xorm:"NOT NULL"`
DoerID int64 `xorm:"INDEX NOT NULL"`
Doer *user_model.User `xorm:"-"`
MergeStyle repo_model.MergeStyle `xorm:"varchar(30)"`
Message string `xorm:"LONGTEXT"`
Expand Down

0 comments on commit c8602a8

Please sign in to comment.